Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language SNAP

(Symbolic Nested Array Processor)

Date:01/03/10
Author:Rod Pullmann
URL:n/a
Comments:0
Info:http://snap-language.ning.com/
Score: (3.50 in 2 votes)
n = 99
nbottles = (n:1:-1) $>"No more"
outa_beer = datatype.each(nbottles)!=INT
plural = ("s","")[`==='.each(nbottles,cast(INT,1))]
todolist = ("Take one down and pass it around"   ...
           ,"Go to the store and buy some more") ...
           [outa_beer]
song = "%s bottle%s of beer on the wall, %s bottle%s of beer.\n" ...
       "%s, %s bottle%s of beer on the wall.\n\n"
m = cat(cat(cat(lam(nbottles,plural)                   ...
               ,lam(lowercase_quant(nbottles),plural)) ...
           ,todolist)                                  ...
       ,lam(lowercase_quant(rot(1,nbottles))           ...
           ,rot(1,plural)))
displ sprintf(song,$>m)

//------------------
func lowercase_quant
{
  textmask = datatype.each(arg)!=INT
  return (merge(textmask            ...
               ,(sel(!textmask,arg) ...
                ,each(`xlat.lower',sel(textmask,arg)))))
}

Download Source | Write Comment

Alternative Versions

Comments

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: