lama_byterun/stdlib/Fun.lama

28 lines
422 B
Text
Raw Normal View History

2020-02-20 12:43:52 +03:00
-- Fun.
-- (C) Dmitry Boulytchev, JetBrains Research, St. Petersburg State University, 2020
--
-- This unit provides some convenient function-manipulation stuff.
import Ref;
public fun id (x) {
x
}
2021-01-12 01:14:18 +03:00
public infixr $ after := (f, x) {
f (x)
}
2020-01-21 22:03:11 +03:00
public infix # after * (f, g) {
fun (x) {
f (g (x))
}
}
public fun fix (f) {
var knot = ref ({});
2020-01-21 22:03:11 +03:00
knot ::= fun (x) {f (deref (knot)) (x)};
2020-01-21 22:03:11 +03:00
deref (knot)
}