-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtutorial.law
37 lines (28 loc) · 900 Bytes
/
tutorial.law
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
ob Base Point = { x: Float, y: Float }
ob Base Bool = [ true: {}, false: {} ]
ar not : Bool --> Bool =
[ true = {} false.,
false = {} true. ]
ob Base ListF =
[ empty: {},
cons: { head: Float, tail: ListF }
]
ob Base ListPoint =
[ empty: {},
cons: { head: Point, tail: ListPoint }
]
ar zip : { xs: ListF, ys: ListF } --> ListPoint =
@xs [ empty = {} empty.,
cons = @ys [ empty = {} empty.,
cons = { head = { x = .xs .head,
y = .ys .head },
tail = { xs = .xs .tail,
ys = .ys .tail } zip
} cons. ] ]
ar ex : {} --> ListF =
empty.
{ head = 0.0, tail = } cons.
{ head = 1.2, tail = } cons.
{ head = 100.0, tail = } cons.
ar main : {} --> ListPoint =
{ xs = ex, ys = ex } zip