@fraczak/k 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Examples/pow.k DELETED
@@ -1,7 +0,0 @@
1
-
2
- pow =
3
- < [(), 0] EQ 1,
4
- [[(), -1] PLUS pow, ()] TIMES
5
- >;
6
-
7
- pow
@@ -1,80 +0,0 @@
1
- $ t = < { t l, int v, t r } t, {} _ >;
2
-
3
- t =
4
- $ {t l, int v, t r}
5
- {() t}
6
- $ t
7
- ;
8
-
9
- empty = {{} _} $t;
10
-
11
- leave =
12
- $ int
13
- { empty l,
14
- () v,
15
- empty r
16
- } t
17
- $ t
18
- ;
19
-
20
- sort =
21
- $ [ int ]
22
- <
23
- SNOC { .0 x, .1 sort t } insert,
24
- { empty l, .0 v, empty r } t,
25
- empty
26
- >
27
- $ t
28
- ;
29
-
30
- insert =
31
- $ { int x, t t }
32
- <
33
- [.t._ , .x leave ] .1,
34
- [[.x, .t.t.v] GT .0, .t.t]
35
- {
36
- .1.l l,
37
- .1.v v,
38
- {.0 x, .1.r t} insert r
39
- } t,
40
- {
41
- {.x x, .t.t.l t} insert l,
42
- .t.t.v v,
43
- .t.t.r r
44
- } t
45
- >
46
- $ t
47
- ;
48
-
49
- inc = $int [(),1] PLUS $int;
50
- len =
51
- < SNOC .1 len inc,
52
- .0 1,
53
- 0
54
- >
55
- ;
56
-
57
- concat =
58
- $ [ [ int ] ]
59
- <
60
- SNOC
61
- < [.0 SNOC, .1] [.0.0, [.0.1, .1] CONS concat ] CONS,
62
- [.0.0, .1 concat] CONS,
63
- .1 concat
64
- >,
65
- .0,
66
- []
67
- >
68
- $ [ int ]
69
- ;
70
-
71
- toVector =
72
- $ t
73
- < ._ [],
74
- .t [.l toVector, [.v], .r toVector] concat
75
- >
76
- $ [ int ]
77
- ;
78
-
79
- [len, sort toVector]
80
-
package/Examples/test.k DELETED
@@ -1,13 +0,0 @@
1
- --------- comments start by #, --, or // ----------------------------------
2
- < -- merge of 4 partial functions...
3
- ["x=", .x, " & y=", .y], -- produces a vector of 4 values, if fields 'x' and 'y' are present
4
- ["only x=", .x], -- produces a pair '["only x=", "value-of-x"]', for input like {"x":"value-of-x"}
5
- -- it is defined only if field 'x' is present
6
- ["only y=", .y],
7
- ["no x nor y"] -- defined for all input, returns always the same one element vector
8
- >
9
- -- one of the string vectors is passed to the following partial function,
10
- -- which produces a record (map) with one field "x&y", whose value is the
11
- -- result of concatenating elements of the passed in vector
12
- { CONCAT "x&y" }
13
- ------------------------------------------------------------------------------
@@ -1,19 +0,0 @@
1
- inc = [(),1] PLUS;
2
- fib2 =
3
- $ { int target, int x, int "fib(x)", int "fib(x-1)" }
4
- _log!
5
- <
6
- {[.target,.x]GT.0 target ,
7
- .x inc x ,
8
- [."fib(x)",."fib(x-1)"]PLUS "fib(x)" ,
9
- ."fib(x)" "fib(x-1)" }
10
- fib2,
11
-
12
- {[.target,.x] EQ, ."fib(x)" result}
13
- .result
14
- >
15
- $ int;
16
-
17
- {() target, 0 x, 1 "fib(x)", 0 "fib(x-1)"} fib2
18
-
19
-