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 OPAL

Date:04/20/05
Author:Maximilian Laiacker
URL:n/a
Comments:0
Info:http://uebb.cs.tu-berlin.de/~opal/
Score: (3.00 in 19 votes)
-- beer.impl
-- 99 Bottles of beer recursively, writen in OPAL
-- By Maximilian Laiacker
-- the OPAL Project: http://uebb.cs.tu-berlin.de/~opal/
IMPLEMENTATION beer

IMPORT Nat COMPLETELY
       Denotation COMPLETELY
       NatConv ONLY `

FUN Bottles: nat -> denotation
DEF Bottles(0)       == "no more bottles"
DEF Bottles(succ(0)) == "1 bottle"
DEF Bottles(n)       == `(n) ++ " bottles"

-- bofb(99) to return the Songtext
DEF bofb(0) == ""
DEF bofb(n) == Bottles(n) ++ " of beer on the wall, " ++
               Bottles(n) ++ " of beer. " ++
               "Take one down, pass it around, " ++
               Bottles(pred(n)) ++ " of beer on the wall.\n" ++ bofb(pred(n))

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: