-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcPrograms.hs
More file actions
67 lines (42 loc) · 711 Bytes
/
Copy pathcPrograms.hs
File metadata and controls
67 lines (42 loc) · 711 Bytes
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
:{
let add1 [] = []
add1 (x:xs) = (x+1) : add1 xs
:}
add1 [1..4]
add1 [1..4]
:{
let power x 0 = 1
power x n = x * power x (n-1)
:}
power 4 3
if
4*262144
let addtwo (x:y:xs) = x + y
addtwo [1..3]
8 5 3 2 1 1
:{
let fasterFib 1 _ = [1,1]
fasterFib n y@(x:x1:xs) = fasterFib (n-1) ff
where ff = (x + x1) : y
:}
ff 1 = [1]
ff 2 = [1,1]
ff 3 = [2,1,1]
head [2,1,1]
head $ tail [2,1,1]
:{
let fib 1 = [1]
fib 2 = [1,1]
fib n = n' + n'' : fibNm1
where n' = head fibNm1
n'' = head $ tail fibNm1
fibNm1 = fib (n-1)
:}
head $ fib 300000
let pl [x,y] = [(x+y),x]
pl [1,1]
:{
let fpl 2 = [1,1]
fpl n = pl $ fpl (n-1)
:}
head $ fpl 300000