Added my code
[fp1415.git] / camil / 2.11 / BottlesOfBeer.icl
1 module BottlesOfBeer
2
3 import StdEnv
4
5 Start = [(fst_line x +++ "\n" +++ snd_line x +++ "\n\n") \\ x <- [99,98..0]]
6
7 fst_line :: Int -> String
8 fst_line n = btl n True +++ wall +++ ", " +++ btl n False +++ " of beer."
9
10 snd_line :: Int -> String
11 snd_line 0 = "Go to the store and buy some more, " +++ btl 99 False +++ wall +++ "."
12 snd_line n = "Take one down and pass it around, " +++ btl (n-1) False +++ wall +++ "."
13
14 btl :: Int Bool -> String
15 btl 0 True = "No more bottles"
16 btl 0 False = "no more bottles"
17 btl 1 b = "1 bottle"
18 btl n b = toString n +++ " bottles"
19
20 wall :: String
21 wall = " of beer on the wall"