mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-28 17:48:47 +00:00
Better scoping in repeat/for, lazy expression (no implicit import yet)
This commit is contained in:
parent
cf78cd20e3
commit
556ce81106
11 changed files with 42 additions and 16 deletions
|
|
@ -1,3 +1 @@
|
|||
> > > 0
|
||||
0
|
||||
5
|
||||
> > > 5
|
||||
|
|
|
|||
10
regression/orig/test104.log
Normal file
10
regression/orig/test104.log
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
> 0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
fun lazy (f) {
|
||||
fun makeLazy (f) {
|
||||
local flag = 0, value = 0;
|
||||
|
||||
return fun () {
|
||||
|
|
@ -12,7 +12,7 @@ fun lazy (f) {
|
|||
}
|
||||
}
|
||||
|
||||
local l = lazy (fun () {write (1); return 800});
|
||||
local l = makeLazy (fun () {write (1); return 800});
|
||||
local x = read ();
|
||||
|
||||
write (l ());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
fun lazy (f) {
|
||||
fun makeLazy (f) {
|
||||
local flag = 0, value = 0;
|
||||
|
||||
fun () {
|
||||
|
|
@ -12,7 +12,7 @@ fun lazy (f) {
|
|||
}
|
||||
}
|
||||
|
||||
local l = lazy (fun () {write (1); 800});
|
||||
local l = makeLazy (fun () {write (1); 800});
|
||||
local x = read ();
|
||||
|
||||
write (l ());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
local x;
|
||||
|
||||
repeat
|
||||
local n = read ();
|
||||
write (n)
|
||||
until n > 0
|
||||
x := n
|
||||
until n > 0;
|
||||
|
||||
write (x)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
0
|
||||
0
|
||||
5
|
||||
5
|
||||
|
|
|
|||
5
regression/test104.expr
Normal file
5
regression/test104.expr
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
local n = read ();
|
||||
|
||||
for local i; i := 0, i<10, i := i + 1 do
|
||||
write (i)
|
||||
od
|
||||
1
regression/test104.input
Normal file
1
regression/test104.input
Normal file
|
|
@ -0,0 +1 @@
|
|||
5
|
||||
Loading…
Add table
Add a link
Reference in a new issue