mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-05 22:38:44 +00:00
New ppx
This commit is contained in:
parent
4e3bdbbbb1
commit
49701ce740
2 changed files with 4 additions and 45 deletions
|
|
@ -12,7 +12,7 @@ $(TESTS): %: %.expr
|
|||
@cat $@.input | $(RC) -s $< > $@.log && diff $@.log orig/$@.log
|
||||
|
||||
clean:
|
||||
rm -f test*.log *.s *~ $(TESTS)
|
||||
pushd expressions && make clean && popd
|
||||
pushd deep-expressions && make clean && popd
|
||||
pushd x86only && make clean && popd
|
||||
$(RM) test*.log *.s *~ $(TESTS)
|
||||
$(MAKE) clean -C expressions
|
||||
$(MAKE) clean -C deep-expressions
|
||||
$(MAKE) clean -C x86only
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
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 ();
|
||||
|
||||
write (0);
|
||||
t := insert (`leaf, 5);
|
||||
write (2);
|
||||
t := insert (t, 4);
|
||||
write (3);
|
||||
t := insert (t, 6);
|
||||
write (4);
|
||||
t := insert (t, 3);
|
||||
write (5);
|
||||
write (find (t, 5));
|
||||
write (6);
|
||||
write (find (t, 4));
|
||||
write (find (t, 6));
|
||||
write (find (t, 3));
|
||||
write (find (t, 2));
|
||||
write (find (t, 1));
|
||||
|
||||
|
||||
t := insert (insert (insert (insert (`leaf, 5), 4), 6), 3)
|
||||
Loading…
Add table
Add a link
Reference in a new issue