diff options
| author | Daniel Cerqueira <dan.git@lispclub.com> | 2025-08-30 17:11:10 +0100 |
|---|---|---|
| committer | Daniel Cerqueira <dan.git@lispclub.com> | 2025-08-30 17:11:55 +0100 |
| commit | 03395835c8719bf5f7a5aee9c97caa61a94f5eee (patch) | |
| tree | a7583f3ae8266d30681f8232cf40b3eeaeea748f /liblali.c | |
| parent | c5df9d66e326e03deb6d0cd00d4679821b0ffa3e (diff) | |
add isSplittedNumber()
also:
- add say() in liblali.h header file
Diffstat (limited to 'liblali.c')
| -rw-r--r-- | liblali.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -1072,6 +1072,41 @@ Object *say(Object *object, GC_PARAM) { return result; } +bool isSplittedNumber(Object *lnum) { + // check the number prefix + if (((lnum)->car->type != TYPE_SYMBOL || + (strcmp((lnum)->car->string, "+") && + strcmp((lnum)->car->string, "-")))) + return false; + + // check the size + Object *list = lnum; + for (int i = 0; i <= 3; i++) + if (list->cdr == nil && i == 0) return false; + else if (list->cdr == nil && i <= 2) break; + else if (i == 3) return false; + else list = list->cdr; + + // check the elements of each sub-list is in between +0 and +9 + list = lnum->cdr; + Object *lcar = nil; + for (;;) { + lcar = list->car; + for (;;) { + if (lcar->car->type != TYPE_NUMBER) + return false; + + if (lcar->cdr == nil) break; + lcar = lcar->cdr; + } + + if (list->cdr == nil) break; + list = list->cdr; + } + + return true; +} + Object *primitiveJoin(Object **args, GC_PARAM) { // check if there are () arguments if ((*args)->car == nil) |
