lama_byterun/regression/test053.lama

42 lines
717 B
Text
Raw Normal View History

2019-09-29 02:47:07 +03:00
local n;
2020-01-14 03:30:17 +03:00
infix === at == (v1, v2) {
local s1, s2, i;
2019-03-25 00:13:42 +03:00
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
}
2020-01-14 03:30:17 +03:00
infix ? before + (v, l) {
2019-03-25 00:13:42 +03:00
case l of
{} -> return 0
2019-04-10 22:15:08 +03:00
| h : tl -> if h === v then return 1 else return (v ? tl) fi
2019-03-25 00:13:42 +03:00
esac
}
2020-01-14 03:30:17 +03:00
infix +++ at + (l1, l2) {
2019-03-25 00:13:42 +03:00
case l1 of
{} -> return l2
2019-04-10 22:15:08 +03:00
| h : tl -> return (h : tl +++ l2)
2019-03-25 00:13:42 +03:00
esac
}
n := read ();
write ({1, 2, 3} === {1, 2, 3});
2019-03-25 00:13:42 +03:00
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})