Skip to content

Instantly share code, notes, and snippets.

@falsetru
Created February 22, 2012 14:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save falsetru/1885373 to your computer and use it in GitHub Desktop.
Save falsetru/1885373 to your computer and use it in GitHub Desktop.
(define H 300)
(define r (/ H 2))
(define (ypos x)
(if (<= x 1)
(/ (sqrt (- 1 (sqr (- (* 2 x) 1)))) 2)
(/ (sqrt (- 1 (sqr (- (* 2 x) 3)))) -2)))
(define (ypos-as-posn x)
(make-posn (* x r)
(* (+ 1 (ypos x)) r)))
(define (div-by n)
(lambda (x) (/ x n)))
(define (range start stop)
(if (<= start stop)
(cons start (range (+ 1 start) stop))
(list)))
(define (do-pairwise action lst)
(if (>= (length lst) 2)
(begin (action (car lst) (cadr lst))
(do-pairwise action (cdr lst)))
'done))
(start H H)
(draw-circle (make-posn r r) r 'black)
(do-pairwise (lambda (a b) (draw-solid-line a b 'black))
(map ypos-as-posn
(map (div-by r) (range 0 H))))
(draw-solid-string (make-posn (* r 0.3) r) "EVAL")
(draw-solid-string (make-posn (* r 1.3) r) "APPLY")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment