From a7d7542dc646a5fd124ef71e71ce260889f1701b Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 2 Feb 2016 19:24:50 +0100 Subject: Moved to 1415 directory --- 1415/fp1/week1/camil/2.11/BottlesOfBeer.icl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 1415/fp1/week1/camil/2.11/BottlesOfBeer.icl (limited to '1415/fp1/week1/camil/2.11') diff --git a/1415/fp1/week1/camil/2.11/BottlesOfBeer.icl b/1415/fp1/week1/camil/2.11/BottlesOfBeer.icl new file mode 100644 index 0000000..70628a1 --- /dev/null +++ b/1415/fp1/week1/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 -- cgit v1.2.3