Last active
December 13, 2015 23:39
-
-
Save FireyFly/4993523 to your computer and use it in GitHub Desktop.
Om language playground
This file contains 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
define { | |
-- { drop } | |
foldl { | |
--{ x0 xs f → v, fold list with function } | |
dequote | |
choose{ | |
rearrange{B}{_ B _} | |
}{ | |
foldl | |
dequote | |
rearrange{D C A B D}{A B C D} | |
<-terms | |
} | |
copy | |
swap | |
} | |
drop{ TODO: returns {objn}{key{val}}, where {objn} is the object the prop was | |
found in, and *not* the initial object (which we actually want). } | |
find' drop{ prop lex → lex lex val, look up Operand in Lexicon including protos } | |
{ dequote choose{ | |
dequote choose{ | |
rearrange{B {}}{_ B _} drop{ obj {} } | |
}{ | |
find' drop{ {?} {?2} } | |
rearrange{C A}{A _ C} drop{ {A} {?} } | |
dequote | |
drop | |
<-terms | |
} | |
copy swap drop{ {?} {?} obj {A} } | |
find{_proto_} drop{ obj {?} {A} } | |
drop drop{ obj {A} } | |
}{ | |
rearrange{B A}{A B _} drop{ obj {?} } | |
} | |
copy swap drop{ {?} {?} obj {A} } | |
find drop{ obj {?} {A} } | |
rearrange{A B A}{A B} drop{ {A} obj {A} } | |
} | |
}{ | |
drop{ foldl{1}{2 3 4 5}{drop} } | |
find' {C} { _proto_{ A{1'} C{3'} } | |
A{1} | |
B{2} } | |
} | |
--{ FIXME: broken! } | |
define { | |
clean { | |
--{ Clears the content of the stack. } | |
dequote | |
choose | |
{clean drop} | |
{drop} | |
= {clean} | |
} | |
}{ | |
clean {1}{2}{3}{4}{5} | |
} | |
define { | |
forever { | |
--{ Applies the given quoted function infinitely on the stack. } | |
rearrange { | |
forever Func | |
dequote Func | |
}{ Func } | |
} | |
}{ | |
forever {drop} {1}{2}{3}{4} | |
} | |
define { | |
-- { drop } | |
on-second { --{ f a .. → a (f ..) } | |
--{ Run a function on the stack-sans-topmost-element, then put back the | |
topmost element afterwards. } | |
rearrange{ A dequote Fn }{ Fn A } | |
} | |
on-third { --{ f a b .. → a b (f ..) } | |
--{ Analogous to `on-second` } | |
rearrange{ A B dequote Fn }{ Fn A B } | |
} | |
on-fourth { --{ f a b c .. → a b c (f ..) } | |
--{ Analogous to `on-second` } | |
rearrange{ A B C dequote Fn }{ Fn A B C } | |
} | |
}{ | |
on-second {literal<- literal<-} {1}{2}{3}{4}{5} | |
} | |
--{ | |
* Alias `drop` as `--` (for comments) (or `N.B.`?) | |
* "Heredocs" for operations | |
* `define` → `let` | |
* Scoping issues | |
* Global `define` á la Scheme (or `set!`?) | |
* Alias `dequote choose` as `if` (?) | |
* Process flags, add `-f` and `-i`. | |
* `on-second` -- runs a function on stack-sans-topmost-element. | |
} | |
--{ | |
lexicon{ A{1}{2} B C{3}{4} } | |
{A{1} | |
B | |
C{3} | |
{4} | |
Om: /home/firefly/prog/repos/Om/code/om/lexicon.cpp:479: static void | |
Om::Lexicon::GiveElements(TheNode*, Om::Queue&) [with TheNode = | |
Om::Lexicon::Node; Om::Queue = Om::Queue]: Assertion `theFirstNode && | |
!theFirstNode->IsEmpty()' failed. | |
zsh: abort (core dumped) ./Om | |
->lexicon{ A{1}{2} }{ A{3} } | |
{{2} | |
A{3} | |
Om: /home/firefly/prog/repos/Om/code/om/lexicon.cpp:479: static void | |
Om::Lexicon::GiveElements(TheNode*, Om::Queue&) [with TheNode = | |
Om::Lexicon::Node; Om::Queue = Om::Queue]: Assertion `theFirstNode && | |
!theFirstNode->IsEmpty()' failed. | |
zsh: abort (core dumped) ./Om | |
lexicon<-{ A{1} }{ A{2}{3} } | |
{{3} | |
A{1} | |
Om: /home/firefly/prog/repos/Om/code/om/lexicon.cpp:479: static void | |
Om::Lexicon::GiveElements(TheNode*, Om::Queue&) [with TheNode = | |
Om::Lexicon::Node; Om::Queue = Om::Queue]: Assertion `theFirstNode && | |
!theFirstNode->IsEmpty()' failed. | |
zsh: abort (core dumped) ./Om | |
} | |
--{ | |
->expression | |
->lexicon | |
->literal | |
->operator | |
<-characters | |
<-code` points | |
<-elements | |
<-forms | |
<-pairs | |
<-terms | |
= | |
characters-> | |
choose | |
code` points-> | |
copy | |
decode | |
define | |
dequote | |
do | |
drop | |
elements-> | |
elements->operand | |
elements->operator | |
elements->separator | |
encode | |
environment | |
evaluate | |
expression | |
expression<- | |
fill | |
find | |
forms-> | |
inject | |
lexicon | |
lexicon<- | |
literal<- | |
normalize | |
operand | |
operand<-elements | |
operator | |
operator<- | |
operator<-elements | |
pairs-> | |
quote | |
rearrange | |
separator | |
separator<-elements | |
skip | |
substitute | |
swap | |
system | |
terms-> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment