Browse Source

Create FunctionSyntax.hs

Abhinav Sarkar 4 years ago
parent
commit
9410b48b01
1 changed files with 30 additions and 0 deletions
  1. 30
    0
      2016-02-23/FunctionSyntax.hs

+ 30
- 0
2016-02-23/FunctionSyntax.hs View File

@@ -0,0 +1,30 @@
1
+module FunctionSyntax where
2
+
3
+sumTill :: Int -> Int
4
+sumTill 1 = 1
5
+sumTill n = n + sumTill (n - 1)
6
+
7
+sumTill' :: Int -> Int
8
+sumTill' n
9
+ | n == 1 = 1
10
+ | otherwise = n + sumTill' (n - 1)
11
+
12
+sumTill'' :: Int -> Int
13
+sumTill'' x = case x of
14
+ 1 | x > 0 -> 1
15
+ _ -> x + sumTill'' (x - 1)
16
+
17
+rot13Char :: Char -> Char
18
+rot13Char c
19
+ | isUpper = undefined
20
+ | isLower = undefined
21
+ | otherwise = error "ERROR"
22
+ where
23
+   isUpper = 'A' <= c && c <= 'Z'
24
+   isLower = 'a' <= c && c <= 'z'
25
+
26
+addOneSquare :: Int -> Int
27
+addOneSquare x =
28
+  let y = x + 1
29
+      z = y + x
30
+  in y * y + z

Loading…
Cancel
Save