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 Gofer

Date:04/20/05
Author:Bow-Yaw Wang
URL:n/a
Comments:0
Info:http://www.cs.yale.edu/HTML/YALE/CS/haskell/yale-fp.html
Score: (1.92 in 12 votes)
Gofer is a variation of Haskell. 
<a href=http://www.cs.yale.edu/HTML/YALE/CS/haskell/yale-fp.html>More Information</a>

-- 99 bottles of beer (gofer version)
-- Written by Bow-Yaw Wang (bywang@saul.cis.upenn.edu)

radix 0 _ = []
radix x n = (x `mod` n):(radix (x/n) n)

itoa x = map (\x -> chr(x + ord('0'))) (reverse (radix x 10))

bottles :: Int -> Dialogue

bottles 1 resps = [AppendChan stdout "1 bottle of beer on the wall, ",
                   AppendChan stdout "1 bottle of beer.\n",
                   AppendChan stdout "Take one down, pass it around, ",
                   AppendChan stdout "no more bottles of beer on the wall.\n"]
bottles n resps = [AppendChan stdout (itoa n),
                   AppendChan stdout " bottles of beer on the wall, ",
                   AppendChan stdout (itoa n),
                   AppendChan stdout " bottles of beer.\n",
                   AppendChan stdout "Take one down, pass it around, ",
                   AppendChan stdout (itoa (n-1)),
                   AppendChan stdout " bottles of beer on the wall.\n"] ++
                   bottles (n-1) resps

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: