author | Tony Garnock-Jones <tonyg@kcbbs.gen.nz> |
Sun, 05 Jul 2009 15:06:54 +0100 | |
changeset 234 | 10e62e160cb0 |
parent 231 | 7881948bd0a9 |
child 235 | 185326ca1c7e |
permissions | -rw-r--r-- |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
1 |
namespace s = "http://eighty-twenty.org/etng/r1/ns/stream#"; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
2 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
3 |
define raw_callcc fn -> |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
4 |
'%assemble' (fn = fn) { .scheme -> ('call-with-current-continuation' |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
5 |
(lambda (k) ('etng-send' fn k))) }; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
6 |
define callcc fn -> |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
7 |
raw_callcc { k -> fn {v -> '%assemble' (v = v, k = k) { .scheme -> (k v) } } }; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
8 |
|
231
7881948bd0a9
Tweak function-extension style
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
230
diff
changeset
|
9 |
define extends extension base -> |
7881948bd0a9
Tweak function-extension style
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
230
diff
changeset
|
10 |
'%assemble' (extension = extension, base = base) { |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
11 |
.scheme -> ('etng-merge-functions' extension base); |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
12 |
}; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
13 |
|
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
14 |
define :booleanBehaviour = rec { |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
15 |
.not -> '%assemble' (x = self) { .scheme -> (not x) }; |
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
16 |
}; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
17 |
|
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
18 |
define :falseProxy = :booleanBehaviour |extends {v -> v.:false}; |
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
19 |
define :trueProxy = :booleanBehaviour |extends {v -> v.:true}; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
20 |
|
225
3250eeca6813
Move 'case' up nearer the top of boot.tng
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
224
diff
changeset
|
21 |
define case x options -> options x; |
3250eeca6813
Move 'case' up nearer the top of boot.tng
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
224
diff
changeset
|
22 |
|
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
23 |
define < = .<; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
24 |
define > = .>; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
25 |
|
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
26 |
define :symbolProxy = rec { |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
27 |
msg -> case self { |
224
91dca64bb782
Correct flaw in < that stops empty (identity) messages from being built.
Tony Garnock-Jones <tonyg@lshift.net>
parents:
221
diff
changeset
|
28 |
.< -> :messageAccumulator {receiver -> receiver} msg; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
29 |
_ -> error("Cannot send message to symbol", msg); |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
30 |
}; |
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
31 |
}; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
32 |
|
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
33 |
define :messageAccumulator firstSender -> { |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
34 |
.> receiver -> firstSender receiver; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
35 |
secondMsg -> :messageAccumulator {receiver -> firstSender receiver secondMsg}; |
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
36 |
}; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
37 |
|
226
1ef6bd84451f
Add <> as syntactic-sugar for (< >)
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
225
diff
changeset
|
38 |
define <> = < >; |
1ef6bd84451f
Add <> as syntactic-sugar for (< >)
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
225
diff
changeset
|
39 |
|
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
40 |
define false = '%assemble' () { .scheme -> (not (quote nonfalse)) }; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
41 |
define true = false.not; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
42 |
|
217
99d5b8250c37
Compile to scheme and evaluate.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
43 |
define + = .+; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
44 |
define * = .*; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
45 |
define == = .==; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
46 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
47 |
define eq x y -> '%assemble' (x = x, y = y) { .scheme -> ('eq?' x y) }; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
48 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
49 |
define write x -> '%assemble' (x = x) { .scheme -> (begin (write x) (newline)) }; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
50 |
|
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
51 |
define :eq = rec { |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
52 |
.== other -> '%assemble' (a = self, b = other) { .scheme -> ('eqv?' a b) }; |
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
53 |
}; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
54 |
|
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
55 |
define :numberProxy = rec { |
217
99d5b8250c37
Compile to scheme and evaluate.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
diff
changeset
|
56 |
.+ other -> '%assemble' (a = self, b = other) { .scheme -> (+ a b) }; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
57 |
.* other -> '%assemble' (a = self, b = other) { .scheme -> (* a b) }; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
58 |
.< other -> '%assemble' (a = self, b = other) { .scheme -> (< a b) }; |
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
59 |
}; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
60 |
|
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
61 |
define s:empty = { .s:case v -> v.s:empty }; |
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
62 |
define s:cons(head, tail) -> { .s:case v -> v.s:next(head, tail) }; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
63 |
|
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
64 |
define :tupleProxy = rec { |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
65 |
.length -> '%assemble' (v = self) { .scheme -> ('vector-length' v) }; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
66 |
.get(n) -> '%assemble' (v = self, n = n) { .scheme -> ('vector-ref' v n) }; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
67 |
.s:case v -> :tupleIterator(self, 0).s:case v; |
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
68 |
}; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
69 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
70 |
define :tupleIterator(tuple, index) -> |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
71 |
(index < (tuple.length)) { |
234
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
72 |
.:true -> {.s:case v -> v.s:next(tuple.get(index), :tupleIterator(tuple, index + 1))}; |
10e62e160cb0
Switch from "[]" to "rec {}", and add "rec selfid {}" form
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
231
diff
changeset
|
73 |
.:false -> {.s:case v -> v.s:empty}; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
74 |
}; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
75 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
76 |
define s:do stream fn -> |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
77 |
stream .s:case { |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
78 |
.s:empty -> .ok; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
79 |
.s:next(head, tail) -> do fn(head); s:do tail fn; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
80 |
}; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
81 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
82 |
define s:foldl stream knil kons -> |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
83 |
stream .s:case { |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
84 |
.s:empty -> knil; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
85 |
.s:next(head, tail) -> s:foldl tail (kons(head, knil)) kons; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
86 |
}; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
87 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
88 |
define s:foldr stream knil kons -> |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
89 |
stream .s:case { |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
90 |
.s:empty -> knil; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
91 |
.s:next(head, tail) -> kons(head, s:foldr tail knil kons); |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
92 |
}; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
93 |
|
228
786b19dd5284
Fix bugs and typo in boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
226
diff
changeset
|
94 |
define s:reverse stream -> s:foldl stream s:empty s:cons; |
786b19dd5284
Fix bugs and typo in boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
226
diff
changeset
|
95 |
define s:append s1 s2 -> s:foldr s1 s2 s:cons; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
96 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
97 |
define s:foldlK stream knil kons k -> |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
98 |
stream .s:case { |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
99 |
.s:empty -> k(knil); |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
100 |
.s:next(head, tail) -> kons (head, knil) {newSeed -> s:foldlK tail newSeed kons k}; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
101 |
}; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
102 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
103 |
define s:foldrK stream knil kons k -> |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
104 |
stream .s:case { |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
105 |
.s:empty -> k(knil); |
228
786b19dd5284
Fix bugs and typo in boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
226
diff
changeset
|
106 |
.s:next(head, tail) -> s:foldrK tail knil kons {newSeed -> kons (head, newSeed) k}; |
221
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
107 |
}; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
108 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
109 |
define s:concatenate stream -> s:foldr stream s:empty s:append; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
110 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
111 |
define s:map stream fn -> s:foldr stream s:empty {elt, acc -> s:cons(fn(elt), acc)}; |
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
112 |
|
eb2506613052
Identifier namespaces, and some interesting code for boot.tng.
Tony Garnock-Jones <tonyg@kcbbs.gen.nz>
parents:
217
diff
changeset
|
113 |
-- s:map (1, 2, 3) {x -> x}; |
230 | 114 |
-- (1, 2, 3) | s:foldr s:empty s:cons | s:do write; |
115 |
-- (1, 2) | s:append (3, 4) | s:do write; |
|
116 |
-- (| s:append (3, 4) | s:do write) (1, 2); |