function(cstr s) cstr:len -> int does
int len=0
while (s|ptr)[len]!=0|byte do
len+=1
done
return len
function(cstr a, cstr b) cstr:__eq__ -> bool does
if a:len()!=b:len() do
return 0|bool
done
int idx=0
while idx<a:len() do
if a:idxi(idx)!=b:idxi(idx) do
return 0|bool
done
idx+=1
done
return 1|bool
function(cstr a, cstr b) cstr:__ne__ -> bool does
return -(a==b)
function(cstr a, ubyte char) cstr:index -> int does
int idx=0
while idx<a:len() do
if a:idxi(idx)|ubyte==char do
return idx
done
idx+=1
done
return -1
function(cstr s, cstr o, int l) cstr:equals_l -> bool does
int i=0
while i<l do
if s[i]!=o[i] do
return false
done
i+=1
done
return true
function(cstr s, cstr o) cstr:startswith -> bool does
return s:equals_l(o, o:len())
function(cstr s) cstr:ord -> int does
return (s|ptr)[0]|int
function(cstr s) char -> ubyte does
return s:ord()|ubyte
function(cstr s, int idx) cstr:idxi -> int does
return (s|ptr)[idx]|int
function(int i) hex_char_to_num -> int does
if i>47 do
if i<58 do
return i-48
else do
return (i-97)+10
done
done
return -1
function(int val, int idx) int:bitset -> bool does
return (val&(1<<idx))!=0
function(bool a, bool b) bool:or -> bool does
if a do
return a
done
return b
function(bool a, bool b) bool:and -> bool does
if a do
if b do
return a
done
done
return 0|bool
function(int n, int p) int:pow -> int does
if p==0 do
return 1
done
int r=n
while p>1 do
p-=1
r*=n
done
return r
function(short n, short p) short:pow -> short does
if p==0|short do
return 1|short
done
short r=n
while p>1|short do
p-=1|short
r*=n
done
return r
function(short s) short:b -> bool does
return (s!=0|short)
function(short s, short o) short:xor -> short does
short i = 0|short
short out = 0|short
while i<16|short do
if (s&(1|short<<i)):b() do
if (o&(1|short<<i))==0|short do
out+=(1|short<<i)
done
else do
if (o&(1|short<<i)):b() do
out+=(1|short<<i)
done
done
i+=1|short
done
return out
function(ptr a, ptr b) ptr:__eq__ -> bool does
return (a|long)==(b|long)
function(ptr a, ptr b) ptr:__ne__ -> bool does
return -(a==b)