diff options
Diffstat (limited to 'one')
-rw-r--r-- | one/twelve.scm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/one/twelve.scm b/one/twelve.scm index 39c3d8b..1e201dc 100644 --- a/one/twelve.scm +++ b/one/twelve.scm @@ -8,7 +8,9 @@ #:export (compute-triangle compute-line display-line - value-at)) + value-at + print-triangle + print-line)) (define (compute-triangle n) (cond ((= n 1) (list (compute-line n 1))) @@ -28,3 +30,17 @@ (else (+ (value-at (- line 1) (- pos 1)) (value-at (- line 1) pos))))) + +;;;; printing + +(define (print-triangle tl level) + (cond ((= (length tl) 0) #t) + (else + (print-triangle (cdr tl) (+ 1 level)) + (print-line (car tl) level)))) + +(define (print-line l level) + (let* ((l (map number->string l)) + (spaces (string-join (make-list level " ") "")) + (line (string-append spaces (string-join l)))) + (format #t "~a\n" line))) |