fork(1) download
  1. ; a partridge in a pear tree
  2.  
  3. (define gifts '(
  4. ("first" "a partridge in a pear tree")
  5. ("second" "two turtle doves")
  6. ("third" "three french hens")
  7. ("fourth" "four calling birds")
  8. ("fifth" "five golden rings")
  9. ("sixth" "six geese a-laying")
  10. ("seventh" "seven swans a-swimming")
  11. ("eighth" "eight maids a-milking")
  12. ("ninth" "nine ladies dancing")
  13. ("tenth" "ten lords a-leaping")
  14. ("eleventh" "eleven pipers piping")
  15. ("twelfth" "twelve drummers drumming")))
  16.  
  17. (define (christmas)
  18. (let loop ((gifts gifts) (rev-gifts (list)))
  19. (when (pair? gifts)
  20. (display "On the ") (display (caar gifts))
  21. (display " day of Christmas my true love gave to me ")
  22. (display (cadar gifts))
  23. (let rev-loop ((rev-gifts rev-gifts))
  24. (when (pair? rev-gifts)
  25. (display (if (< 1 (length rev-gifts)) ", " " and "))
  26. (display (cadar rev-gifts))
  27. (rev-loop (cdr rev-gifts))))
  28. (display ".") (newline)
  29. (loop (cdr gifts) (cons (car gifts) rev-gifts)))))
  30.  
  31. (christmas)
Success #stdin #stdout 0.02s 8672KB
stdin
Standard input is empty
stdout
On the first day of Christmas my true love gave to me a partridge in a pear tree.
On the second day of Christmas my true love gave to me two turtle doves and a partridge in a pear tree.
On the third day of Christmas my true love gave to me three french hens, two turtle doves and a partridge in a pear tree.
On the fourth day of Christmas my true love gave to me four calling birds, three french hens, two turtle doves and a partridge in a pear tree.
On the fifth day of Christmas my true love gave to me five golden rings, four calling birds, three french hens, two turtle doves and a partridge in a pear tree.
On the sixth day of Christmas my true love gave to me six geese a-laying, five golden rings, four calling birds, three french hens, two turtle doves and a partridge in a pear tree.
On the seventh day of Christmas my true love gave to me seven swans a-swimming, six geese a-laying, five golden rings, four calling birds, three french hens, two turtle doves and a partridge in a pear tree.
On the eighth day of Christmas my true love gave to me eight maids a-milking, seven swans a-swimming, six geese a-laying, five golden rings, four calling birds, three french hens, two turtle doves and a partridge in a pear tree.
On the ninth day of Christmas my true love gave to me nine ladies dancing, eight maids a-milking, seven swans a-swimming, six geese a-laying, five golden rings, four calling birds, three french hens, two turtle doves and a partridge in a pear tree.
On the tenth day of Christmas my true love gave to me ten lords a-leaping, nine ladies dancing, eight maids a-milking, seven swans a-swimming, six geese a-laying, five golden rings, four calling birds, three french hens, two turtle doves and a partridge in a pear tree.
On the eleventh day of Christmas my true love gave to me eleven pipers piping, ten lords a-leaping, nine ladies dancing, eight maids a-milking, seven swans a-swimming, six geese a-laying, five golden rings, four calling birds, three french hens, two turtle doves and a partridge in a pear tree.
On the twelfth day of Christmas my true love gave to me twelve drummers drumming, eleven pipers piping, ten lords a-leaping, nine ladies dancing, eight maids a-milking, seven swans a-swimming, six geese a-laying, five golden rings, four calling birds, three french hens, two turtle doves and a partridge in a pear tree.