-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhaskellFun3.hs
More file actions
49 lines (41 loc) · 1.23 KB
/
haskellFun3.hs
File metadata and controls
49 lines (41 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import Data.Char
squarePairs :: Int -> Integer -> [(Integer,Integer)]
squarePairs n i
| n <= 0 = []
| otherwise = (i,i^2) : squarePairs (n-1) (i+1)
countDownBy :: Int -> Int -> Int -> [Int]
countDownBy m n diff
| m < n = []
| otherwise = m : countDownBy (m-diff) n diff
steps :: Int -> Int -> [[Int]]
steps m n
| n <= 0 = []
| otherwise = helper 1
where
helper :: Int -> [[Int]]
helper i
| i > (n-m)+1 = []
| otherwise = countUp m ((m+i)-1) : helper (i+1)
countUp :: Int -> Int -> [Int]
countUp m n
| m > n = []
| otherwise = m : countUp (m+1) n
indexChar :: Int -> Int -> Char -> String
indexChar n i c
| n <= 0 = []
| otherwise = helper 1
where
helper :: Int -> String
helper y
| y > n || i < 1 = []
| y == i = '!' : helper (y+1)
| otherwise = c : helper (y+1)
diag :: Int -> Char -> [String]
diag n c
| n <= 0 = []
| otherwise = helper 1
where
helper :: Int -> [String]
helper i
| i > n = []
| otherwise = indexChar n i c : helper (i+1)