learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-4.scm (672B)


      1 ;; Exercise 2.4
      2 
      3 (import (srfi 64))
      4 
      5 (test-begin "chapter-2-exercise-4")
      6 
      7 (let ((cons (lambda (x y) (lambda (m) (m x y))))
      8       (car (lambda (z) (z (lambda (p q) p))))
      9       (cdr (lambda (z) (z (lambda (p q) q)))))
     10 
     11 
     12   (for-each
     13    (lambda (matsui) (test-equal 'x matsui))
     14    (list (car (cons 'x 'y))
     15          (car (lambda (m) (m 'x 'y)))
     16          ((lambda (m) (m 'x 'y)) (lambda (p q) p))
     17          ((lambda (p q) p) 'x 'y)))
     18   (for-each
     19    (lambda (matsui) (test-equal 'y matsui))
     20    (list (cdr (cons 'x 'y))
     21          (cdr (lambda (m) (m 'x 'y)))
     22          ((lambda (m) (m 'x 'y)) (lambda (p q) q))
     23          ((lambda (p q) q) 'x 'y))))
     24 
     25 (test-end "chapter-2-exercise-4")