-
Notifications
You must be signed in to change notification settings - Fork 0
/
017.scm
22 lines (22 loc) · 1.17 KB
/
017.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(define (e17)
(let1 v (make-vector 1001 "")
(for-each (^(i s) (vector-set! v i s))
(iota 19 1)
'("one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve" "thirteen" "fourteen" "fifteen" "sixteen" "seventeen" "eighteen" "nineteen"))
(for-each (^(i s)
(for-each (^j
(vector-set! v (+ i j) (string-append s (vector-ref v j))))
(iota 10)))
(iota 9 20 10)
'("twenty" "thirty" "forty" "fifty" "sixty" "seventy" "eighty" "ninety"))
(for-each (^i
(for-each (^j
(vector-set! v (+ (* i 100) j)
(string-append (vector-ref v i) "hundred"
(if (not (zero? j))
(string-append "and" (vector-ref v j))
""))))
(iota 100)))
(iota 9 1))
(vector-set! v 1000 "onethousand")
(apply + (map (^i (string-length (vector-ref v i))) (iota 1000 1)))))