diff options
author | Mart Lubbers | 2015-02-05 21:05:24 +0100 |
---|---|---|
committer | Mart Lubbers | 2015-02-05 21:05:24 +0100 |
commit | f3e414502693dbc8b190f2df211404c81217603d (patch) | |
tree | 8a3f39e3064e7f45b687b23315d1cc8e78e116f7 /camil/2.11 | |
parent | week1: mart (diff) | |
parent | Added my code (diff) |
Merge branch 'master' of github.com:dopefishh/fp1
Diffstat (limited to 'camil/2.11')
-rw-r--r-- | camil/2.11/BottlesOfBeer.icl | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/camil/2.11/BottlesOfBeer.icl b/camil/2.11/BottlesOfBeer.icl new file mode 100644 index 0000000..70628a1 --- /dev/null +++ b/camil/2.11/BottlesOfBeer.icl @@ -0,0 +1,21 @@ +module BottlesOfBeer
+
+import StdEnv
+
+Start = [(fst_line x +++ "\n" +++ snd_line x +++ "\n\n") \\ x <- [99,98..0]]
+
+fst_line :: Int -> String
+fst_line n = btl n True +++ wall +++ ", " +++ btl n False +++ " of beer."
+
+snd_line :: Int -> String
+snd_line 0 = "Go to the store and buy some more, " +++ btl 99 False +++ wall +++ "."
+snd_line n = "Take one down and pass it around, " +++ btl (n-1) False +++ wall +++ "."
+
+btl :: Int Bool -> String
+btl 0 True = "No more bottles"
+btl 0 False = "no more bottles"
+btl 1 b = "1 bottle"
+btl n b = toString n +++ " bottles"
+
+wall :: String
+wall = " of beer on the wall"
\ No newline at end of file |