mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 14:58:50 +00:00
19 lines
273 B
Text
19 lines
273 B
Text
|
|
fun lazy (f) {
|
||
|
|
local flag = 0, value = 0;
|
||
|
|
|
||
|
|
return fun () {
|
||
|
|
if flag
|
||
|
|
then return value
|
||
|
|
else
|
||
|
|
value := f ();
|
||
|
|
flag := 1;
|
||
|
|
return value
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
local l = lazy (fun () {write (1); return 800});
|
||
|
|
local x = read ();
|
||
|
|
|
||
|
|
write (l ());
|
||
|
|
write (l ())
|