diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-04-05 21:31:39 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-04-05 21:31:39 -0700 |
commit | 9c51abd7297034b9b109eafcf01021fbd2876ba4 (patch) | |
tree | ecaf2d7eed8ea106e193c4811301df87a39d3981 /cppawk-include | |
parent | 26dba3a636e0587e621941842bf0af96afa45f97 (diff) | |
download | cppawk-9c51abd7297034b9b109eafcf01021fbd2876ba4.tar.gz cppawk-9c51abd7297034b9b109eafcf01021fbd2876ba4.tar.bz2 cppawk-9c51abd7297034b9b109eafcf01021fbd2876ba4.zip |
New function equalize.
Diffstat (limited to 'cppawk-include')
-rw-r--r-- | cppawk-include/cons-priv.h | 30 | ||||
-rw-r--r-- | cppawk-include/cons.h | 1 |
2 files changed, 27 insertions, 4 deletions
diff --git a/cppawk-include/cons-priv.h b/cppawk-include/cons-priv.h index 8a57215..3ce5873 100644 --- a/cppawk-include/cons-priv.h +++ b/cppawk-include/cons-priv.h @@ -216,6 +216,7 @@ function __box_str(__str) { return "T" __str } +#define __box_str(str) ("T" (str)) function __box_sym(__name) { @@ -382,16 +383,37 @@ function __slow_equal(__obj1, __obj2, } if (__tc1 == "T") - return __unbox(__obj1) == __obj2; + return __numberp(__obj2) ? 0 : (__obj1 == __box_str(__obj2)) if (__tc2 == "T") - return __obj1 == __unbox(__obj2); + return __numberp(__obj1) ? 0 : (__box_str(__obj1) == __obj2) - if (__numberp(__obj1) && __numberp(__obj2)) { + if (__numberp(__obj1) && __numberp(__obj2)) return __obj1 + 0 == __obj2 + 0 + + return 0 +} + +function __equalize(__obj, + __tc, __str) +{ + if (!__present(__obj)) + return "" + + __tc = __typecode(__obj) + + __case (__tc) { + __of("C") + __cret (__cons(__equalize(__car(__obj)), + __equalize(__cdr(__obj)))) + __of("T", "S", "U", "") + __cret (__obj) } - return 0; + if (__numberp(__obj)) + return __obj + 0 + + return __box_str(__obj) } function __pack(__stk, __item) diff --git a/cppawk-include/cons.h b/cppawk-include/cons.h index 560784a..0087930 100644 --- a/cppawk-include/cons.h +++ b/cppawk-include/cons.h @@ -69,6 +69,7 @@ #define ltof __ltof #define keys __keys #define equal __equal +#define equalize __equalize #define list __list #define li __li #define listar __listar |