learning-sicp

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

exercise-10.scm (497B)


      1 (define-library (sicp solutions chapter-1 exercise-10)
      2   (import (scheme base))
      3   (export A
      4           f
      5           g
      6           h
      7           k)
      8 
      9   (begin
     10     (define (A x y)
     11       ;; SICP lied to us!  This is not the Ackermann functinon!
     12       (cond ((= y 0) 0)
     13             ((= x 0) (* 2 y))
     14             ((= y 1) 2)
     15             (else (A (- x 1)
     16                      (A x (- y 1))))))
     17 
     18     (define (f n) (A 0 n))
     19 
     20     (define (g n) (A 1 n))
     21 
     22     (define (h n) (A 2 n))
     23 
     24     (define (k n) (* 5 n n))))