diff --git a/test/str.ul b/test/str.ul deleted file mode 100644 index 9dc0946..0000000 --- a/test/str.ul +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Constants - */ -const str nl = "\n"; - -/** - * Print with a newline - */ -function pln(str string) { - for (byte c in string) { - putchar(c); - } - putchar(nl); -} - -/** - * Concatinates 2 strings - */ -function strcat(str src1, str src2) str { - str result = malloc(src1.length + src2.length); - memcpy(&result[0], &src1); - memcpy((&result + src1.length), &src2); - return result; -} - -/** - * finds index of string, -1 if not found - */ -function stridx(str haystack, byte needle) int { - int i = -1; - for (byte c in haystack) { - i = i + 1; - if (c == needle) { - break; - } - } - return i; -} - -/** - * checks if 2 strings are equal - */ -function streq(str src1, str src2) bool { - if (src1.length != src2.length) return false; - for (int i=0; src1.length; i++) { - if (src1[i] != src2[i]) return false; - } - return true; -} - -/** - * Slice string - */ -function slice(str src, int start, int stop) str { - int len = stop - start; - str result = malloc(len); - for (int i=start; i 0); - - if(neg) buffer[--i] = '-'; - - str result = malloc(6 - i); - memcpy(result, &buffer[0] + i, 6 - i); - return result; -} - -/** - * nat to string - */ -function ntos(nat src) str { - byte buffer[5]; - nat i = 5; - - do { - buffer[--i] = '0' + n % 10; - n /= 10; - } while(n > 0); - - str result = malloc(5 - i); - memcpy(result, &buffer[0] + i, 5 - i); - return result; -} - -/** - * real to string - */ -function rtos(real src) str { - -} - -/** - * string to int - */ -function stoi(str src) int { - -} - -/** - * string to nat - */ -function ston(str src) nat { - -} - -/** - * string to real - */ -function stor(str src) real { - -}