lama_byterun/stdlib/Lazy.lama

14 lines
183 B
Text
Raw Normal View History

public fun makeLazy (f) {
local value, set = false;
fun () {
2020-02-15 22:58:43 +03:00
if set
then value
else set := true; value := f (); value
fi
}
}
public fun force (f) {
f ()
}