More stdlib; memoized CPS parser combinators workout

This commit is contained in:
Dmitry Boulytchev 2020-01-20 03:38:43 +03:00
parent b05ad7f6b1
commit 1027d988fc
10 changed files with 253 additions and 7 deletions

24
stdlib/Fun.expr Normal file
View 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) ()
}