-
Notifications
You must be signed in to change notification settings - Fork 1
/
list.pro
53 lines (43 loc) · 897 Bytes
/
list.pro
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
let Cons{first rest}<
case "car" \cust:
send cust (first)
;
case "cdr" \cust:
send cust (rest)
;
>
let First <
case \list \cust: send list ("car" cust) ;
>
let Last <
case \list \cust:
send list ("cdr" <
case null: send list ("car" cust) ;
case \val:
send Last (val <
case \val: send cust (val) ;
>)
;
>)
;
>
let ForEach <
case null \cust: ;
case \list \cust:
send list ("car" cust)
send list ("cdr" <
case \val: send ForEach (val cust) ;
>)
;
>
let Square <
case \list \cust:
send ForEach (list <
case \val: send val ("*" val cust) ;
>)
;
>
let a Cons{1 Cons{2 Cons{3 Cons{4 null}}}}
send Square (a stdout)
//send First (a stdout)
//send Last (a stdout)