[an error occurred while processing this directive]
(define (list-cruncher base proc combiner lst) (if (null? lst) base (combiner (proc (car lst)) (list-cruncher base proc combiner (cdr lst))))) (define (sumlist p) (list-cruncher _____ ___________________ _____ p)) (define (map f p) (list-cruncher _______ ______ ______ p)) (define (length p) (list-cruncher ______ _____________ + p))Why would it be impossible to correctly define list? using just list-cruncher?
Define find-closest-number, a procedure that takes two
parameters, a goal and a list of numbers, and produces the number in the
list numbers list that is closest to goal.
(define (find-closest-number goal numbers) (if (= 1 (length numbers)) (car numbers) (if (< (abs (- goal (car numbers))) (abs (- goal (find-closest goal (cdr numbers))))) (car numbers) (find-closest goal (cdr numbers))))) (define (find-closest goal lst closeness) (if (= 1 (length lst)) (car lst) (if (< (closeness goal (car lst)) (closeness goal (find-closest goal (cdr lst) closeness))) (car lst) (find-closest goal (cdr lst) closeness)))) (define (pick-closest closeness goal num1 num2) (if (< (closeness goal num1) (closeness goal num2)) num1 num2)) (define (find-closest goal lst closeness) (if (= 1 (length lst)) (car lst) (pick-closest closeness goal (car lst) (find-closest goal (cdr lst) closeness))))
What is the difference between RTN and BNF?
Song ::= Verse VBBD VBBD Better CodaChallenge Problem
VBBD ::= Verse Bridge Bridge Dadada (ends on C)
Coda ::= F Eb Bb F Coda
Note: the Coda has no base case, and should continue forever (time permitting).