Scheme - create a function from a list of functions -


hey i'm having trouble thinking , help.

in scheme if i'm given list of functions (list square - double) need make function encompass list

for example

(let (f (co (list square - double))))  co function name combines 

would same

(square (- (double n))) n number can following (f 2) => (16)   (define (co functions) (lambda (n) (? functions))) 

i'm not sure go ?. know if map end getting functions applied number output list '(4 -2 4).

any ideas appreciated

hopefully it's not homework.

> (define double (lambda (n) (* n 2))) > (define square (lambda (n) (* n n))) > (set! fs (list square - double)) > (define co     (lambda (functions n)       (cond          ((null? functions) n)         (else ((car functions) (co (cdr functions) n)))))) > (co fs 6) 144 > (co fs 4) 64 > (co fs 2) 16 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -