(Extra credit use iota0 and fill-list to make some long lists, and use time to time how long your sort takes on them, and plot the results. Be sure to use lists long enough to give you a significant digit, and repeat your timing tests a couple times to check for consistency. And get enough data points, so we can really see how your code's performance scales.)
(define add1 (lambda (x) (+ x 1))) (to-leaves add1 '(1 (1000 2000) 5)) ; (2 (1001 2001) 6)
(ineval '(23)) ; 23 (ineval '(1 + 2)) ; 3 (ineval '-17) ; -17 (ineval '(1 + 2 * 3)) ; 7 = 1+(2*3) (ineval '(1 * 2 + 3)) ; 5 = 1*(2+3) (ineval '(2 * 2 + 3 * 3)) ; 22 = 2*(2+(3*3)) (ineval '((1 + 1) * (2 + 2))) ; 8 (ineval '(1 + (2 * 2 * 2) + 1000)) ; 1009 (ineval '(- 1000)) ; -1000 (ineval '(- 1 + 17)) ; -18 = -(1+17) (ineval '(10 + - 1 + 1)) ; 8 = 10+-(1+1) (ineval '(10 + (- 1 + 1) + 1000)) ; 1008 = 10+-(1+1)+1000 (ineval '(2 * - 3 + 4)) ; -14 ;;; These are examples of malformed ineval expressions - you do not ;;; have to handle them. (ineval '(2 - * 3 + 4)) (ineval '-) (ineval '+) (ineval '*) (ineval '()) (ineval #t) (ineval '(* 2)) (ineval '(3 - 1))