diff options
Diffstat (limited to 'liblali.c')
| -rw-r--r-- | liblali.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -66,6 +66,35 @@ void exceptionWithObject(Object *object, char *format, ...) { longjmp(exceptionEnv, 1); } + +// STRINGS //////////////////////////////////////////////////////////////////// + +bool hasADot(char *string) { + for (int i = 0; string[i] != '\0'; i++) + if (string[i] == '.') + return true; + return false; +} + +void revString(char* string) { + // Initialize l and r pointers + int l = 0; + int r = strlen(string) - 1; + char t; + + // Swap characters till l and r meet + while (l < r) { + // Swap characters + t = string[l]; + string[l] = string[r]; + string[r] = t; + + // Move pointers towards each other + l++; + r--; + } +} + // GARBAGE COLLECTION ///////////////////////////////////////////////////////// /* This implements Cheney's copying garbage collector, with which memory is |
