1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; Standard Library Procedures and Macros ;;
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10 ; Join two lists together
14 (cons (car l1) (join (cdr l1) l2))))
16 ; Append an arbitrary number of lists together
17 (define (append . lists)
20 (if (null? (cdr lists))
22 (join (car lists) (apply append (cdr lists))))))
26 (define-macro (let value . body )
27 (list (list 'lambda (list (car value)) body)) (cdr value))
31 ; Basic iterative summation. Run this on large numbers to
32 ; test garbage collection and tail-call optimization.
35 (define (sum-iter total count maxcount)
36 (if (> count maxcount)
38 (sum-iter (+ total count) (+ count 1) maxcount)))
42 ; Recursive summation. Use this to compare with tail call
43 ; optimized iterative algorithm.
44 (define (sum-recurse n)
47 (+ n (sum-recurse (- n 1)))))