Commits

Murali Suriar committed 1edd3e0 Merge

Merge foo into default?

  • Participants
  • Parent commits 821adf0, 21d40e5

Comments (0)

Files changed (5)

+fac 0 = 1
+fac n = n * fac (n-1)
+main = putStrLn "Hello world"

File lyah/scratch.hs

+doubleMe x = x + x
+
+doubleUs x y = doubleMe x + doubleMe y
+
+
+doubleSmallNumber x = if x > 100
+                        then x
+                        else doubleMe x
+
+doubleSmallNumber' x = (if x > 100 then x else doubleMe x) + 1
+
+fac :: Int -> Int
+fac n = product [ 1 .. n ]
+
+circumference :: Float -> Float
+circumference r = 2 * pi * r
+
+
+bmiTell :: (Fractional a, Ord a) => a -> a -> String
+bmiTell weight height
+  | (bmi weight height) <= skinny = "Skinny."
+  | (bmi weight height) <= normal = "Normal."
+  | (bmi weight height) <= fat = "Fat."
+  | otherwise = "Monstrous!"
+  where bmi weight height = weight / height ^ 2
+        skinny = 18.5
+        normal = 25.0
+        fat = 30.0
+main = do putStrLn "What is 2+2?"
+          x <- readLn
+          if x == 4
+            then putStrLn "Right!"
+            else putStrLn "Wrong!"

File questionfac.hs

+fac n = if n == 0
+         then 1
+         else n * fac (n-1)
+
+main = do putStrLn "What is 5! ?"
+          x <- readLn
+          if x == fac 5
+            then putStrLn "Right!"
+            else putStrLn "Wrong!"