From dab7f4eb2a11e7dec118f9e5618a52d4a2a1c511 Mon Sep 17 00:00:00 2001 From: d_m Date: Thu, 11 Apr 2024 19:03:25 -0400 Subject: [PATCH] binary string --- demo.modal | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/demo.modal b/demo.modal index 5ea513f..7caa03a 100644 --- a/demo.modal +++ b/demo.modal @@ -41,6 +41,13 @@ <> (reverse' ?a nil) (?a) <> (reverse' ?a (?h ?t)) (reverse' (?h ?a) ?t) +-- map +<> (map ?f (list ?l)) (map/l map/f ?f ?l) +<> (map/f ?f (?h ?t)) (?f ?h (map/f ?f ?t)) +<> (map/f ?f (?h)) (map/r (?f ?h)) +<> (?h (map/r ?t)) (map/r (?h ?t)) +<> (map/l map/r ?l) (list ?l) + -- ( normalize, remove trailing zeros ) -- ( currently zero is (0 nil) though arguably it could be nil ) -- ( that change would require auditing our rules ) @@ -57,6 +64,18 @@ <> (f (?u) nil) (nil) <> (f (?u) (?h ?t)) (((mul ?h ?u) f ((mul ?u ten)) ?t)) +-- ( to binary str ) +<> ((bstr ?x)) ((bstr1 ?x)) +<> ((bstr1 (0 nil))) ((0 (b 0))) +<> ((bstr1 (1 nil))) ((0 (b 1))) +<> ((bstr1 (0 (0 ?c)))) ((bstr2 ?c (0 0))) +<> ((bstr1 (1 (0 ?c)))) ((bstr2 ?c (0 1))) +<> ((bstr1 (0 (1 ?c)))) ((bstr2 ?c (1 0))) +<> ((bstr1 (1 (1 ?c)))) ((bstr2 ?c (1 1))) +<> ((bstr2 nil ?z)) ((stringify (0 (b ?z)))) +<> ((bstr2 (0 ?t) ?z)) ((bstr2 ?t (0 ?z))) +<> ((bstr2 (1 ?t) ?z)) ((bstr2 ?t (1 ?z))) + -- ( to string: TODO, need division for this one ) <> ((str ?x)) ((str1 (divmod ?x ten) nil)) <> ((str1 (?q ?r) ?a)) ((str2 ?q (?r ?a))) @@ -100,8 +119,6 @@ <> ((digitize 8 ?a)) ((stringify (8 ?a))) <> ((digitize 9 ?a)) ((stringify (9 ?a))) -<> ((stringify ?*)) (?*) - -- ( comparison operartions ) <> ((cmp ?x ?y)) ((cmpc #eq ?x ?y)) <> ((cmpc ?e nil nil)) (?e) @@ -198,4 +215,7 @@ <> ((mod ?x ?y)) ((mod' (divmod ?x ?y))) <> ((mod' (?q ?r))) (?r) -(str (mul (int 235) (int 345))) +-- ( stringify ) +<> ((stringify ?*)) (?*) + +(bstr (mul (int 2399) (int 3499)))