Created
December 22, 2016 04:03
-
-
Save niyarin/d358741e88f9c1fa276a0b99f2862ddf to your computer and use it in GitHub Desktop.
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
(define decorate #f) | |
(let ((pos-seed 1) | |
(shape-seed 1)) | |
(set! decorate | |
(lambda (leaves) | |
(for-each | |
(lambda (_) | |
(set! pos-seed (modulo (+ (* pos-seed 3) 7) 26)) | |
(set! shape-seed (modulo (+ shape-seed 1) 3)) | |
(if (< pos-seed (string-length leaves)) | |
(string-set! leaves pos-seed | |
(list-ref '(#\@ #\? #\$) shape-seed)))) | |
(make-list 3)) | |
leaves))) | |
(define tree-data | |
(let loop1 ((width '( 0 2 6 10 ))(updates '(1 1 2 2 ) )) | |
(if (null? width) | |
'() | |
(append | |
(let loop2 ((w (min 1 (car width)))) | |
(if (> w (car width)) | |
'() | |
(cons | |
(string-append | |
(substring " " 0 (- 13 w)) | |
(decorate (substring "*****************************" 0 (+ (* w 2) 1)))) | |
(loop2 (+ w (car updates) ))))) | |
(loop1 (cdr width)(cdr updates)))))) | |
(define tree-pot | |
(let ((space " ") | |
(edge "| |") | |
(bottom "-------")) | |
(append | |
(map (lambda (_) | |
(string-append space edge)) | |
(make-list 2 )) | |
(list (string-append space bottom))))) | |
(for-each | |
(lambda (x) (display x)(newline)) | |
(append tree-data tree-pot)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment