LHC explained
So, the LHC is on the news again. If you have missed it last year, don't miss it this time:
Large Hadron Rap
Large Hadron Rap
I hope there's pudding
USING: combinators io kernel make math math.parser sequences ;
IN: 99bottles
: bottles ( n -- str )
{
{ 0 [ "no more bottles" ] }
{ 1 [ "1 bottle" ] }
[ number>string " bottles" append ]
} case ;
: verse-0 ( n -- )
drop
"No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall."
print ;
: verse-n ( n -- )
[ dup bottles % " of beer on the wall, " % dup bottles %
" of beer.\nTake one down and pass it around, " %
1 - bottles % " of beer on the wall.\n" % ] "" make
print ;
: verse ( n -- )
dup 0 number= [ verse-0 ] [ verse-n ] if ;
: 99bottles ( -- )
100 reverse [ verse ] each ;
MAIN: 99bottles
Labels: Factor