mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Massive renaming
This commit is contained in:
parent
241ab0a9ae
commit
61296c51e7
152 changed files with 45 additions and 29 deletions
32
regression/test039.lama
Normal file
32
regression/test039.lama
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
local n, t;
|
||||
|
||||
fun insert (t, x) {
|
||||
case t of
|
||||
Leaf -> return Node (x, Leaf, Leaf)
|
||||
| Node (y, l, r) -> if x > y
|
||||
then return Node (y, insert (l, x), r)
|
||||
else return Node (y, l, insert (r, x))
|
||||
fi
|
||||
esac
|
||||
}
|
||||
|
||||
fun find (t, x) {
|
||||
case t of
|
||||
Leaf -> return 0
|
||||
| Node (y, l, r) -> if x == y then return 1
|
||||
elif x > y then return find (l, x)
|
||||
else return find (r, x)
|
||||
fi
|
||||
esac
|
||||
}
|
||||
|
||||
n := read ();
|
||||
|
||||
t := insert (insert (insert (insert (Leaf, 5), 4), 6), 3);
|
||||
|
||||
write (find (t, 5));
|
||||
write (find (t, 4));
|
||||
write (find (t, 6));
|
||||
write (find (t, 3));
|
||||
write (find (t, 2));
|
||||
write (find (t, 1))
|
||||
Loading…
Add table
Add a link
Reference in a new issue