3 ms·
That's something I'm working on, actually. I think matching the top stack item(s) fits well into a postfix stack-oriented language. For example: TYPE: Tree
by PeCaN 10y ago
That's something I'm working on, actually. I think matching the top stack item(s) fits well into a postfix stack-oriented language. For example:
TYPE: Tree
| Branch(Tree,Tree)
| Leaf
;
:: depth Tree -> Int ;
: Branch($,$) depth {depth} dip depth + ;
: Leaf depth 1 ;
$ is extract, so the pattern Branch($,$) pops the top of the stack and pushes the 2 members. Types and type constructors have to start with a capital letter, but I like the
: Pattern word definition ;
syntax a lot.