Created
December 17, 2013 00:28
-
-
Save bunyk/7997787 to your computer and use it in GitHub Desktop.
Don't beet me too hard.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; while loop | |
(define (while condition body) | |
(if (condition) | |
(begin | |
(body) | |
(while condition body) | |
) | |
(list) | |
) | |
) | |
; for loop | |
(define (for setup condition increment body) | |
(begin | |
(setup) | |
(while condition | |
(lambda () (begin | |
(body) | |
(increment) | |
)) | |
) | |
) | |
) | |
; importing turtle functions | |
(define turtle (import (quote turtle))) | |
(define forward (getattr turtle (quote forward))) | |
(define right (getattr turtle (quote right))) | |
(define (pentagram size) | |
(begin | |
(define i 0) | |
(for | |
(lambda () (set! i 0)) | |
(lambda () (< i 5)) | |
(lambda () (set! i (+ i 1))) | |
(lambda () (begin | |
(forward size) | |
(right (- 180 36)) | |
)) | |
) | |
) | |
) | |
(pentagram 100) | |
(forward 100) | |
(pentagram 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment