mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-05 22:38:44 +00:00
Infixes
This commit is contained in:
parent
fe4e322d58
commit
eae2367371
5 changed files with 218 additions and 88 deletions
6
regression/orig/test053.log
Normal file
6
regression/orig/test053.log
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
> 1
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
||||
1
|
||||
39
regression/test053.expr
Normal file
39
regression/test053.expr
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
infix "===" at "==" (v1, v2) local s1, s2, i {
|
||||
s1 := v1.string;
|
||||
s2 := v2.string;
|
||||
|
||||
if s1.length == s2.length
|
||||
then
|
||||
for i := 0, i < s1.length, i := i + 1
|
||||
do
|
||||
if s1[i] != s2[i] then return 0 fi
|
||||
od;
|
||||
return 1
|
||||
else return 0
|
||||
fi
|
||||
}
|
||||
|
||||
infix "?" before "+" (v, l) {
|
||||
case l of
|
||||
{} -> return 0
|
||||
| h : tl -> if h === v then return 1 else return v ? tl fi
|
||||
esac
|
||||
}
|
||||
|
||||
infix "+++" at "+" (l1, l2) {
|
||||
case l1 of
|
||||
{} -> return l2
|
||||
| h : tl -> return h : tl +++ l2
|
||||
esac
|
||||
}
|
||||
|
||||
n := read ();
|
||||
|
||||
write ({1, 2, 3} === {1, 2, 3});
|
||||
write ({1, 2, 3} === {1, 2, 4});
|
||||
write (1+2 ? {1, 2, 3});
|
||||
write (1*3+2 ? {1, 2, 3});
|
||||
write (1*3+2 ? {1, 2, 5});
|
||||
write (8*4 ? {1, 2, 3} +++ {5, 7, 32, 6})
|
||||
|
||||
|
||||
1
regression/test053.input
Normal file
1
regression/test053.input
Normal file
|
|
@ -0,0 +1 @@
|
|||
0
|
||||
Loading…
Add table
Add a link
Reference in a new issue