Name:
Anonymous
2008-12-24 22:21
(define (christmasTree h)
(define (foo k)
(if (< k 1)
"" (string-append " " (foo (- k 1)))))
(define (bar k)
(if (< k 1)
"\n" (string-append "*" (bar (- k 1)))))
(define (ct i)
(if (= i (+ h 1))
(string-append
(foo (- h 1))
(bar 1))
(string-append
(foo (- h i))
(bar (- (* 2 i) 1))
(ct (+ i 1)))))
(display (ct 1)))
#;1> (christmasTree 10)
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
*
Name:
Anonymous
2009-03-06 17:47
▲
▲ ▲
▲ ▲ ▲
▲ ▲ ▲ ▲
▲ ▲ ▲ ▲ ▲
▲ ▲ ▲ ▲ ▲ ▲
▲ ▲ ▲ ▲ ▲ ▲ ▲
▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲
▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲
▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲
▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲
▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲
▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲
▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
▼ ▼ ▼ ▼ ▼ ▼ ▼
▼ ▼ ▼ ▼ ▼ ▼
▼ ▼ ▼ ▼ ▼
▼ ▼ ▼ ▼
▼ ▼ ▼
▼ ▼
▼