1 ! Copyright (C) 2011 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: ascii combinators combinators.smart io kernel math
4 math.parser ranges sequences splitting ;
7 : bottles ( n -- number string )
8 [ dup 0 > [ number>string ] [ drop "No more" ] if ]
9 [ 1 = not "bottles" "bottle" ? ] bi ;
14 [ bottles "of beer on the wall," ]
15 [ bottles "of beer.\nTake one down, pass it around," ]
16 [ 1 - bottles [ >lower ] dip "of beer on the wall." ]
18 ] output>array join-words print nl ;
21 "No more bottles of beer on the wall, no more bottles of beer." print
22 "Go to the store and buy some more, 99 bottles of beer on the wall." print ;
25 99 1 [a..b] [ verse ] each last-verse ;