mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-05 22:38:44 +00:00
28 lines
No EOL
422 B
Text
28 lines
No EOL
422 B
Text
-- 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
|
|
}
|
|
|
|
public infixr $ after := (f, x) {
|
|
f (x)
|
|
}
|
|
|
|
public infix # after * (f, g) {
|
|
fun (x) {
|
|
f (g (x))
|
|
}
|
|
}
|
|
|
|
public fun fix (f) {
|
|
var knot = ref ({});
|
|
|
|
knot ::= fun (x) {f (deref (knot)) (x)};
|
|
|
|
deref (knot)
|
|
} |