diff options
| -rw-r--r-- | liblali.c | 35 | ||||
| -rw-r--r-- | liblali.h | 4 |
2 files changed, 39 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) @@ -333,6 +333,10 @@ Object *primitiveGreater(Object **args, GC_PARAM); bool hasADot(char *string); +Object *say(Object *object, GC_PARAM); + +bool isSplittedNumber(Object *lnum); + Object *primitiveJoin(Object **args, GC_PARAM); Object *primitiveSplit(Object **args, GC_PARAM); |
