(define make-add (lambda (a) (lambda (b) (+ a b)))) (define add4 (make-add 4)) (add4 5) `(a b ,((lambda (a) `(test . ,a)) 69) c d) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define fib (lambda (c) (_fib 0 1 0 c))) (define _fib (lambda (a b n c) (if (= n c) b (_fib b (+ a b) (+ n 1) c)))) (define do (lambda (c f) (_do f '() 0 c))) (define _do (lambda (f r n c) (if (= n c) r (_do f (cons (f n) r) (+ n 1) c)))) ;; comment ;; another comment ;; fib(13) ;(do 10 (lambda (n) (display (fib n)))) ; comment ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define +list (lambda (l) (_+list l 0))) (define _+list (lambda (l acc) (if (nil? l) acc (_+list (cdr l) (+ acc (car l)))))) (+list '(10 12)) (define * (lambda (a n) (+list (do n (lambda (n) a))))) (* 9 7) (define reverse (lambda (l) (_reverse l '()))) (define _reverse (lambda (l n) (if (nil? l) n (_reverse (cdr l) (cons (car l) n))))) ;; (+list (do 100 (lambda (n) (fib n)))) (reverse (do 100 (lambda (n) (fib n)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; don't know about a good example (defmacro m (a) `(+ ,a 57)) (m (+ 1 2)) (define cadr (lambda (l) (car (cdr l)))) (define map (lambda (fn list) (if (nil? list) list (cons (fn (car list)) (map fn (cdr list)))))) (map (lambda (n) (+ n 1)) '(1 2 3)) (defmacro let (vars body) `((lambda ,(map car vars) ,body) . ,(map cadr vars))) (let ((a 8) (b 9)) (+ a b))