
Concept explainers
Write a function in Scheme or rules in Prolog called countlt that takes a list of numbers, L, and another number, N, and returns the count of numbers less than N in the list L.
Example calls
Scheme:
(countlt '(6 1 9 ) 4) -> 1
((countlt '(50 27 13 ) 1 )-> 0
Prolog
?- countlt ( [6, 1, 9], 4, X).
X = 1.
?- countlt([SO, 27, 13], 1, X)
X = 0.
( define countlt (lambda (L N )
(cond
((null? L ) 0 )
((< ( car L) N) (+ 1 (countlt (cdr L ) N )))
((else (countlt (cdr L ) N)))))
countlt([], _, 0).
counttl([H|T], N, X ): -
H >= N,
countlt(T,N, X ).
countlt([H|T, N,X
countlt ((T,N,C),
H < N, X is C + 1.

Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

- Given the following graph, represent it in Python (syntax counts) using: An adjacency list. Dictionaries with adjacency sets. An adjacency matrix.arrow_forwardCan someone pls explain to me ASAP??!!! Write a Scheme function named elements which counts the number of elements in a list; for example: (elements '(1 (2 (3) 4) 5 6)) is 6, while the length of the same list is 4.arrow_forwarddef optimize_tail_calls(original_scheme_eval): """Return a properly tail recursive version of an eval function.""" def optimized_eval(expr, env, tail=False): """Evaluate Scheme expression EXPR in Frame ENV. If TAIL, return an Unevaluated containing an expression for further evaluation. """ if tail and not scheme_symbolp(expr) and not self_evaluating(expr): return Unevaluated(expr, env) result = Unevaluated(expr, env) # fill in code code here while isinstance(result, Unevaluated): #code here return optimized_eval scheme_eval = optimize_tail_calls(scheme_eval)arrow_forward
- write in c++ Given a class declaration for a list implemented using a linked list (like NumberList) implement some of the functions (like the constructor, the destructor, append a node to the end, remove the last node, remove the node in position i, etc).arrow_forwardJava/Data Structures: The Java Class Library implementation of the interface list return null when an index is out of range. True or Falsearrow_forwardTheory of computation: Write a program using c++ and pseudo code to check if the entering value following the grammar or not without checking if the grammar is left recursion or not: E ---> E + T | T T---> T * F | F F---> (E) | i Thanks in advance ( I hope you solve it fast with the right answer if you can't solve it leave it please! )arrow_forward
- Let the function fun be defined as: int fun(int &k) { k += 4; return 3 * k -1; } Suppose the function fun was used in a program as follows: void main() { int i = 10, j = 10, sum1, sum2; sum1 = (i / 2) + fun(i); sum2 = fun(j)) + ( j / 2); } A. What are the values of sum1 and sum2 if the operands in the expressions are evaluated left to right? B. What are the values of sum1 and sum2 if the operands in the expressions are evaluated right to left?arrow_forwardWrite a function two in Scheme that takes a single parameter, a list of integers. The function tworeturns #t if the list of integers includes two equal integers. Otherwise, it returns #f. The list L isflat, i.e., it does not contain sublists.arrow_forwardI need the answer as soon as possiblearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





