ReZero's Utopia.

SICP lec1b: # Computing process

Word count: 94Reading time: 1 min
2017/12/03 Share

Computing process

心智

kinds of expressions

number symbols


lambda definations conditionals


combinations


condition

if (define (+ x u) (if (= x 0) y (+ (-1 x) (1 y)) ) )

Fibonacci

(define (fib n)
    (if (< n 2)
        n
        (+  (fib (- n 1))
            (fib (- n 1))
        )
    )
)

tips: 1+ function means add args 1 and return


Hanoi Tower

(define (dohanoi n to from using)
  (if (> n 0)
      (begin
        (dohanoi (- n 1) using from to)
        (display "move ")
        (display from)
        (display " --> ")
        (display to)
        (newline)
        (dohanoi (- n 1) to using from)
        #t)
      #f))

(define (hanoi n)
    (dohanoi n 3 1 2))
CATALOG
  1. 1. Computing process
    1. 1.0.1. kinds of expressions
    2. 1.0.2. condition
    3. 1.0.3. Fibonacci
    4. 1.0.4. Hanoi Tower