lama_byterun/regression/test087.expr

42 lines
682 B
Text
Raw Normal View History

2020-01-05 03:33:17 +03:00
local n;
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;
1
else 0
fi
}
infix "?" before "+" (v, l) {
case l of
{} -> 0
| h : tl -> if h === v then 1 else (v ? tl) fi
esac
}
infix "+++" at "+" (l1, l2) {
case l1 of
{} -> l2
| h : tl -> (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})