-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.pfx
124 lines (92 loc) · 1.58 KB
/
test.pfx
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
$def nil [];
$def true #t;
$def false #f;
$def not:a $if a false true;
$def || a b
$if = a true
true
$if = b true
true
false;
$memdef && a b not:|| not:a not:b;
$def - a b + a -b;
$def > a b not:<= a b;
$def < a b && not:= a b <= a b;
$def >= a b not:< a b;
$def head:[hd .._]
hd;
$def tail:[_ ..rest]
rest;
$memdef ^ x exp
$if = exp 0
1
* x ^ x - exp 1;
$memdef \any any;
$memdef nth_fib:n (
$if = n 0
1
$if = n 1
1
+ nth_fib:- n 1 nth_fib:- n 2
);
$def is_even:n
= 0 % n 2;
$memdef range: min max
$if = min max
[]
cons: min range: + min 1 max;
$def map: _ [] [];
$memdef map: fn [hd ..rest]
cons: fn:hd map: fn rest;
$def len:[] 0;
$memdef len:[_ ..rest]
+ 1 len:rest;
$memdef filter: fn list
$if = list nil
nil
(
$def hd head:list;
$if fn:hd
cons: hd filter: fn tail:list
filter: fn tail:list
);
$memdef flip:fn
$fn a b fn: b a;
$memdef ,func
$fn a [a func:a];
$memdef . fn_a fn_b
$fn x fn_a:fn_b:x;
$memdef @ fn param
$fn x fn: param x;
$memdef apply: fn param
fn:param;
$def do_print:a
print:a;
$memdef !! i [hd ..rest]
$if = i 0
hd
!! - i 1 rest;
$def hash_get: [] key
#none;
$def hash_get: [[k v] ..rest] key
$if = k key
v
hash_get: rest key;
$def memoize_unary:fn?fn (
$def memo mut.[];
$fn a (
$def stored hash_get: !memo a;
$if = stored #none
(
$def out fn:a;
set! memo cons: [a out] memo;
out
)
stored
)
);
$def takes_many_types:[int?_ str?_ list?_ fn?_] #none;
$def first_arg_pred: pred pred:val val;
$def empty:[.._] #f;
$def empty:[] #t;
first_arg_pred: (list?) []