From 9410b48b012bd46c263697242f4ae28e87d76f22 Mon Sep 17 00:00:00 2001 From: Abhinav Sarkar Date: Tue, 23 Feb 2016 23:08:17 +0530 Subject: [PATCH] Create FunctionSyntax.hs --- 2016-02-23/FunctionSyntax.hs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 2016-02-23/FunctionSyntax.hs diff --git a/2016-02-23/FunctionSyntax.hs b/2016-02-23/FunctionSyntax.hs new file mode 100644 index 0000000..dda0b60 --- /dev/null +++ b/2016-02-23/FunctionSyntax.hs @@ -0,0 +1,30 @@ +module FunctionSyntax where + +sumTill :: Int -> Int +sumTill 1 = 1 +sumTill n = n + sumTill (n - 1) + +sumTill' :: Int -> Int +sumTill' n + | n == 1 = 1 + | otherwise = n + sumTill' (n - 1) + +sumTill'' :: Int -> Int +sumTill'' x = case x of + 1 | x > 0 -> 1 + _ -> x + sumTill'' (x - 1) + +rot13Char :: Char -> Char +rot13Char c + | isUpper = undefined + | isLower = undefined + | otherwise = error "ERROR" + where + isUpper = 'A' <= c && c <= 'Z' + isLower = 'a' <= c && c <= 'z' + +addOneSquare :: Int -> Int +addOneSquare x = + let y = x + 1 + z = y + x + in y * y + z