mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-05 22:38:44 +00:00
19 lines
No EOL
257 B
Text
19 lines
No EOL
257 B
Text
fun makeLazy (f) {
|
|
local flag = 0, value = 0;
|
|
|
|
fun () {
|
|
if flag
|
|
then value
|
|
else
|
|
value := f ();
|
|
flag := 1;
|
|
value
|
|
fi
|
|
}
|
|
}
|
|
|
|
local l = makeLazy (fun () {write (1); 800});
|
|
local x = read ();
|
|
|
|
write (l ());
|
|
write (l ()) |