Paste: 99bob
Author: | Arrogant |
Mode: | factor |
Date: | Tue, 10 Aug 2010 08:26:58 |
Plain Text |
clear 100 iota reverse but-last [| n |
n number>string " bottle" n 1 = [ "s" append ] unless
" of beer on the wall, " n number>string pick
" of beer!" append append append append append print
"Take one down, pass it around, " print
n 1 - dup 0 =
[ "no" ]
[ dup number>string ] if
" more bottle" n 2 = [ "s" append ] unless
" of beer on the wall!" append append print "" print drop
] each
Author: | Arrogant |
Mode: | factor |
Date: | Tue, 10 Aug 2010 08:36:16 |
Plain Text |
: bottle(s) ( n -- bottle-string )
" bottle" swap 1 = [ "s" append ] unless
;
clear 99 1 [a,b] [| n |
n number>string n bottle(s)
" of beer on the wall, " n number>string pick
" of beer!" append append append append append print
"Take one down, pass it around, " print
n 1 - dup 0 =
[ "no" ]
[ dup number>string ] if
" more " n 1 - bottle(s) append
" of beer on the wall!" append append print nl drop
] each
Author: | pruned |
Mode: | factor |
Date: | Tue, 10 Aug 2010 08:39:36 |
Plain Text |
[ 10 1 [a,b] [| n |
[ n # " bottle" % n 1 = [ "s" % ] unless " of beer" % ] "" make
[ % " on the wall, " % ] [ % "!\n" % ] bi
"Take one down, pass it around, \n" %
n 1 = [ "no" % ] [ n 1 - # ] if
" more bottle" % n 2 = [ "s" % ] unless
" of beer on the wall!\n\n" %
] each ] "" make print nl
Author: | pruned |
Mode: | factor |
Date: | Tue, 10 Aug 2010 08:50:06 |
Plain Text |
[ 10 1 [a,b] [| n |
n present " bottle" append
n 1 = [ "s" append ] unless
" of beer" append
[ % " on the wall, " % ] [ % "!\n" % ] bi
"Take one down, pass it around, \n" %
n 1 = [ "no" % ] [ n 1 - # ] if
" more bottle" % n 2 = [ "s" % ] unless
" of beer on the wall!\n\n" %
] each ] "" make print nl
Author: | Arrogant |
Mode: | factor |
Date: | Tue, 10 Aug 2010 09:08:17 |
Plain Text |
: bottle(s) ( n -- bottle-string )
" bottle" swap 1 = [ "s" append ] unless
;
[ 99 1 [a,b] [| n |
n present n bottle(s)
" of beer" append
[ % " on the wall, " % ] [ % "!\n" % ] bi
"Take one down, pass it around, \n" %
n 1 = [ "no" % ] [ n 1 - # ] if
" more" % n 1 - bottle(s) %
" of beer on the wall!\n\n" %
] each ] "" make print nl
Author: | pruned |
Mode: | factor |
Date: | Tue, 10 Aug 2010 09:20:31 |
Plain Text |
: bottles ( n str -- str )
swap
{
{ 0 [ "no" " bottles" ] }
{ 1 [ "1" " bottle" ] }
[ present " bottles" ]
} case surround ;
[ 10 1 [a,b] [| n |
n "" bottles " of beer" append
[ % " on the wall, " % ] [ % "!\n" % ] bi
"Take one down, pass it around, \n" %
n 1 - " more" bottles % " of beer on the wall!\n\n" %
] each ] "" make print nl
Author: | Arrogant |
Mode: | factor |
Date: | Tue, 10 Aug 2010 10:09:06 |
Plain Text |
: bottle(s) ( n -- str )
" bottle" over 1 = [ "s" append ] unless
[ dup 0 = [ drop "no more" ] [ present ] if ] dip append
;
[ 10 1 [a,b] [| n |
n bottle(s) " of beer" append
[ % " on the wall, " % ] [ % "!\n" % ] bi
"Take one down, pass it around, \n" %
n 1 - bottle(s) % " of beer on the wall!\n\n" %
] each ] "" make print nl
Author: | pruned |
Mode: | factor |
Date: | Tue, 10 Aug 2010 10:16:09 |
Plain Text |
: bottles ( n str -- str )
swap
{
{ 0 [ "no" " bottles" ] }
{ 1 [ "1" " bottle" ] }
[ present " bottles" ]
} case surround ;
[ 10 1 [a,b] [
[ "" bottles " of beer" append
[ % " on the wall, " % ] [ % "!\n" % ] bi
"Take one down, pass it around, \n" % ]
[ 1 - " more" bottles % " of beer on the wall!\n\n" % ] bi
] each ] "" make print
New Annotation