University of Virginia Computer Science CS150: Computer Science, Fall 2005 |
(none) 14 September 2005 |
For example, (compose square square) should produce a procedure
that take input x and produces x4.
What should ((compose (lambda (x) (+ x 1)) (lambda (x) (* x 2))) 3) evaluate to?
Define a procedure n-times that takes two operands: a
procedure p and a number n, and produces the composition of the
procedure with itself n times.
For example, ((n-times (lambda (x) (+ x 1)) 5) 7) should evaluate to 12 and ((n-times (lambda (x) (* x 2)) 0) 4) should evaluate to 4.
(define (simple-sort cf lst) (if (null? lst) lst (let ((best (find-best cf lst))) (cons best (simple-sort cf (delete lst most)))))) (define (find-best cf lst) (insertl (lambda (c1 c2) (if (cf c1 c2) c1 c2)) lst (car lst))) (define (insertsort cf lst) (if (null? lst) null (insertone cf (car lst) (insertsort cf (cdr lst))))) (define (insertone cf el lst) (if (null? lst) (list el) (if (cf el (car lst)) (cons el lst) (cons (car lst) (insertone cf el (cdr lst))))))
I am also the student whose 6th grade home-room teacher
wrote, "Less social involvement and more academic diligence is in
order".
Neil deGrasse
Tyson's Speech
at the State Department to winners of the Presidential Award for
Excellence in Mathematics and Science Teaching
"); print ( $res[$first] ) ; print (" |
CS 150: Computer Science University of Virginia |
evans@virginia.edu Using these Materials |