teaching machines

CS 330 Lecture 34 – Scope and eval

April 27, 2012 by . Filed under cs330, lectures, spring 2012.

Agenda

Program This

Pick one:

Code

lsystem.ss

(define first car)
(define rest cdr)

(define apply-productions-once
  (lambda (loa alist)
    (cond
      ((null? loa) '())
      (else (append 
             (rest (assoc (first loa) alist))
             (apply-productions-once (rest loa) alist))))))

(define apply-productions-n-times
  (lambda (loa alist n)
    (cond
      ((= n 0) loa)
      (else (apply-productions-n-times 
             (apply-productions-once loa alist)
             alist
             (- n 1))))))

(define lsystem
  (lambda (start productions angle n)
    (apply-productions-n-times start productions n)))

(lsystem '(F - F - F - F)
         '((F F - F + F + F F - F - F + F)
           (- -)
           (+ +))
         90
         1)

Haiku

Do it once by hand.
To see what work your code saves.
John Henry found out.