From 7bc67b95161a34f8eca635d4000d9602508a9243 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Mon, 23 Dec 2019 01:32:39 +0000 Subject: checkpoint --- examples/e.int | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/e.int (limited to 'examples/e.int') diff --git a/examples/e.int b/examples/e.int new file mode 100644 index 0000000..f49b406 --- /dev/null +++ b/examples/e.int @@ -0,0 +1,21 @@ +[type cons [(INT head) (cons tail)]] +[def (INT ==) [(INT a) (INT b)] [if [- a b] 0 1]] +[def (INT hastail) [(INT list)] [if [cons.tail list] 1 0]] +[def (INT carry_guess) [(INT d) (INT base)] [/ d base]] +[def (INT remainder) [(INT d) (INT base)] [% d base]] +[def (INT carry_propagate) [(INT a) (INT b)] [+ 1 1]] +[def (INT next_carry) [(INT base) (INT ds)] + [carry_propagate [+ base 1] [cons.tail ds]]] +[def (INT d_corrected) [(INT base) (INT ds)] + [+ [cons.head ds] [next_carry base ds]]] + +[def (INT carry_propagate) [(INT base) (INT ds)] [ + if [== [carry_guess [cons.head ds] base] [/ [+ [cons.head ds] 9] base]] + [cons [carry_guess [cons.head ds] base] + [+ [remainder [cons.head ds] base] [next_carry base [cons.tail ds]]]] + [cons [/ d_corrected base] [% d_corrected base]] +]] + +[def (INT e) [(INT n)] + [ +[def (INT inter_main) [] [debug_int [+ 1 1]]] -- cgit v1.2.1