mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-07 23:38:47 +00:00
More stdlib; memoized CPS parser combinators workout
This commit is contained in:
parent
b05ad7f6b1
commit
1027d988fc
10 changed files with 253 additions and 7 deletions
24
stdlib/Fun.expr
Normal file
24
stdlib/Fun.expr
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import Ref;
|
||||
|
||||
public fun id (x) {
|
||||
x
|
||||
}
|
||||
|
||||
public infixl $ after * (f, x) {
|
||||
f (x)
|
||||
}
|
||||
|
||||
public infix # at $ (f, g) {
|
||||
fun (x) {
|
||||
f (g (x))
|
||||
}
|
||||
}
|
||||
|
||||
public fun fix (f) {
|
||||
local knot = ref (0);
|
||||
|
||||
knot ::= fun () {fun (x) {f (deref (knot) ()) (x)}};
|
||||
|
||||
|
||||
deref (knot) ()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue