length := fn(ptr: ^u8): int { len := 0 loop if *(ptr + len) == 0 break else len += 1 return len } display_int := fn(num: int, p: ^u8): ^u8 { i := 0 if num == 0 { *p = 48 return p } loop if num == 0 break else { *(p + i) = num % 10 + 48 num /= 10 i += 1 } @inline(reverse, p); *(p + i) = 0 return p } reverse := fn(s: ^u8): void { //reverse a string, don't remove digits len := 0 loop if *(s + len) == 0 break else len += 1 i := 0 j := len - 1 temp := 0 loop if i >= j break else { temp = *(s + i); *(s + i) = *(s + j); *(s + j) = temp i += 1 j -= 1 } return }