binary string

This commit is contained in:
~d6 2024-04-11 19:03:25 -04:00
parent 4e2a1d21e0
commit dab7f4eb2a
1 changed files with 23 additions and 3 deletions

View File

@ -41,6 +41,13 @@
<> (reverse' ?a nil) (?a) <> (reverse' ?a nil) (?a)
<> (reverse' ?a (?h ?t)) (reverse' (?h ?a) ?t) <> (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 ) -- ( normalize, remove trailing zeros )
-- ( currently zero is (0 nil) though arguably it could be nil ) -- ( currently zero is (0 nil) though arguably it could be nil )
-- ( that change would require auditing our rules ) -- ( that change would require auditing our rules )
@ -57,6 +64,18 @@
<> (f (?u) nil) (nil) <> (f (?u) nil) (nil)
<> (f (?u) (?h ?t)) (((mul ?h ?u) f ((mul ?u ten)) ?t)) <> (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 ) -- ( to string: TODO, need division for this one )
<> ((str ?x)) ((str1 (divmod ?x ten) nil)) <> ((str ?x)) ((str1 (divmod ?x ten) nil))
<> ((str1 (?q ?r) ?a)) ((str2 ?q (?r ?a))) <> ((str1 (?q ?r) ?a)) ((str2 ?q (?r ?a)))
@ -100,8 +119,6 @@
<> ((digitize 8 ?a)) ((stringify (8 ?a))) <> ((digitize 8 ?a)) ((stringify (8 ?a)))
<> ((digitize 9 ?a)) ((stringify (9 ?a))) <> ((digitize 9 ?a)) ((stringify (9 ?a)))
<> ((stringify ?*)) (?*)
-- ( comparison operartions ) -- ( comparison operartions )
<> ((cmp ?x ?y)) ((cmpc #eq ?x ?y)) <> ((cmp ?x ?y)) ((cmpc #eq ?x ?y))
<> ((cmpc ?e nil nil)) (?e) <> ((cmpc ?e nil nil)) (?e)
@ -198,4 +215,7 @@
<> ((mod ?x ?y)) ((mod' (divmod ?x ?y))) <> ((mod ?x ?y)) ((mod' (divmod ?x ?y)))
<> ((mod' (?q ?r))) (?r) <> ((mod' (?q ?r))) (?r)
(str (mul (int 235) (int 345))) -- ( stringify )
<> ((stringify ?*)) (?*)
(bstr (mul (int 2399) (int 3499)))