The Twelve Days of Christmas: Difference between revisions
→{{header|Scheme}}: Now works in Chez, Guile, MIT Scheme, and Racket.
(→{{header|Scheme}}: Now works in Chez, Guile, MIT Scheme, and Racket.) |
|||
Line 4,851:
=={{header|Scheme}}==
Without Common Lisp's <tt>format</tt>, we sadly have to hard-code the list of ordinals.
<lang scheme>
(define (take lst n)
(if (or (null? lst) (<= n 0))
'()
(cons (car lst) (take (cdr lst) (- n 1
(let
Line 4,868 ⟶ 4,869:
(do ((left days (cdr left))
; No universal predefined (+ 1) function, sadly. Implementations
(day 1 (1+ day)))▼
; are divided between (add1) and (1+).
((null? left) #t)
Line 4,876 ⟶ 4,879:
(newline)
(do ((daily (reverse (take
((null? daily) #t)
|