This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val ensuring: p do: b := { | |
res = b call: [val] | |
p call: [val] | |
res | |
} call | |
with-output-to: (fn: String) do: b := | |
Port (new: fn) ensuring: @close do: { file | | |
with-input-from: file do: b | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"writan to the terminal" print | |
with-output-to: "foo.txt" do: { | |
"writan to foo.txt" print | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ the | |
> foo := dispatch sender x | |
> foo | |
message not understood: (<reference> x) | |
> x = 0 | |
> foo | |
0 | |
> { x = 42; foo } call | |
42 | |
> x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTML = Object clone | |
Association = Object clone | |
a -> b := Association clone do: { from = a; to = b } | |
Self-Closing = ["base", "meta", "link", "hr", "br", "param", "img", "area", "input", "col", "frame"] | |
-- creating elements with no content | |
-- keyword dispatch adds attributes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(b: Block) key: (v: Object) := { | |
find = { l | | |
l match: { | |
[] -> @nothing | |
(e . es) -> | |
if: (e values head evaluate == v) | |
then: { @(ok: (e values (at: 1) evaluate)) } | |
else: { find call: [es] } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import The.Haskell | |
load = do | |
"(x: Object) clone" =: do | |
Reference r <- getSymbol "x" | |
proto <- newProto $ \p -> p | |
{ vpDelegates = [r] | |
} | |
return (Reference proto) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(b: Block) in-scope := | |
Object clone do: { | |
delegates-to: b | |
call := b scope do: b | |
call: vs := b scope do: b with: vs | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> (x: Block) .. (y: Block) = Block new: (x contents .. y contents) | |
> {a = 1} .. {a + 1} | |
{a = 1; (a + 1)} | |
> ({a = 1} .. {a + 1}) evaluate do | |
2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> import: "prelude/expression.hs" | |
> Expression Block new | |
{} | |
> Expression Block new: [] | |
{} | |
> Expression Block new: [1] | |
{1} | |
> Expression Block new: [1, 2] | |
{1; 2} | |
> Expression Block new: { a = 1; a + 2 } contents |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
problem-1: max = { | |
(0 ... max) | |
(filter: { n | 3 divides?: n || 5 divides?: n }) | |
sum | |
} do | |
(problem-1: 1000) print |