[FUNC @CONCAT [[PARAM !pars [ARRAY $STRING]] [RETURNS $STRING]] [ [DEFINE !len 0] [DEFINE !i 0] [WHILE [< !i [LEN !pars]] [ [DEFINE !len [+ !len [LEN [GET !pars !i]]]] [DEFINE !i [+ !i 1]] ]] [DEFINE !out [NEW $STRING !len]] [DEFINE !i 0] [WHILE [< !i [LEN !pars]] [ [DEFINE !j 0] [DEFINE !par [GET !pars !i]] [WHILE [< !j [LEN !par]] [ [APPEND !out [GET !par !j]] [DEFINE !j [+ !j 1]] ]] [DEFINE !i [+ !i 1]] ]] [RETURN !out] ]] [FUNC @REVERSE [[PARAM !v $STRING] [RETURNS $STRING]] [ [DEFINE !start 0] [DEFINE !end [- [LEN !v] 1]] [WHILE [< !start !end] [ # Swap [DEFINE !buf [GET !v !start]] [SET !v !start [GET !v !end]] [SET !v !end !buf] # Increment [DEFINE !start [+ !start 1]] [DEFINE !end [- !end 1]] ]] [RETURN !v] ]] [FUNC @ITOA [[PARAM !v [INT]] [RETURNS $STRING]] [ [IF [= !v 0] [RETURN "0"] []] [DEFINE !out [NEW $STRING]] # Handle negatives [DEFINE !negative [@FALSE]] [IF [< !v 0] [ [DEFINE !negative [@TRUE]] [DEFINE !v [* -1 !v]] ] []] # Go through digits [WHILE [NEQ !v 0] [ [DEFINE !rem [% !v 10]] [IF [> !rem 9] [ [APPEND !out '0'] ] [ [APPEND !out [+ '0' [TOC !rem]]] ]] [DEFINE !v [/ !v 10]] ]] [IF !negative [ [APPEND !out '-'] ] []] [RETURN [@REVERSE !out]] ]] # Adapted from https://stackoverflow.com/a/46678932/11388343, but wrong -- lots of trailing 0s and doesn't work with numbers with 0s after decimal (e.g. 123.000123), or numbers like 0.123 [FUNC @FTOA [[PARAM !v [FLOAT]] [RETURNS $STRING]] [ # Get leading [DEFINE !start [@ITOA [@FLOOR !v]]] # Get trailing [DEFINE !m [@FLOOR !v]] [WHILE [NEQ [@FLOOR !v] [@CEIL !v]] [ [DEFINE !m [* !m 10]] [DEFINE !v [* !v 10.0]] ]] [DEFINE !dec [- [@FLOOR !v] !m]] [DEFINE !end [@ITOA [@ABS !dec]]] [RETURN [@CONCAT [ARR !start "." !end]]] ]] [FUNC @BTOA [[PARAM !v [BOOL]] [RETURNS $STRING]] [ [IF !v [ [RETURN "TRUE"] ] [ [RETURN "FALSE"] ]] ]] [FUNC @STREQ [[PARAM !l $STRING] [PARAM !r $STRING] [RETURNS [BOOL]]] [ [IF [NEQ [LEN !l] [LEN !r]] [[RETURN [@FALSE]]] []] [DEFINE !i 0] [WHILE [< !i [LEN !l]] [ [IF [NEQ [GET !l !i] [GET !r !i]] [ [RETURN [@FALSE]] ] []] [DEFINE !i [+ !i 1]] ]] [RETURN [@TRUE]] ]] [FUNC @TOLOWER [[PARAM !v $STRING] [RETURNS $STRING]] [ [DEFINE !res [NEW $STRING [LEN !v]]] [DEFINE !i 0] [WHILE [< !i [LEN !v]] [ [DEFINE !c [GET !v !i]] [IF [| [> !c '@'] [< !c '[']] [DEFINE !c [+ !c [TOC 32]]] []] [APPEND !res !c] [DEFINE !i [+ !i 1]] ]] [RETURN !res] ]] [FUNC @CTOA [[PARAM !v [CHAR]] [RETURNS $STRING]] [ [DEFINE !res [NEW $STRING 1]] [APPEND !res !v] [RETURN !res] ]]