fun -char !findChar -string &str -char &char set &idx 0 getstrsize $str &len @loop equal $idx $len &store if $store %end getstrcharat $str $idx &stridx equal $stridx $char &store if $store %return add $idx 1 &idx jump %loop @return return $idx @end endfun fun -char !findCharInstance -string &str -char &char -int &instance set &idx 0 getstrsize $str &len @loop equal $idx $len &store if $store %end getstrcharat $str $idx &stridx equal $stridx $char &store if $store %decrement @increment add $idx 1 &idx jump %loop @decrement equal $instance 0 &store if $store %return subtract $instance 1 &instance jump %increment @return return $idx @end endfun fun -string !mid -string &str -int &idx -int &len set &ans "" lesser $idx 0 &store if $store %end @loop getstrsize $str &store equal $store $idx &store if $store %end getstrcharat $str $idx &store add $ans $store &ans add $idx 1 &idx getstrsize $ans &store equal $store $len &store if $store %return jump %loop @return return $ans @end endfun fun -string !inBrackets -string &str -char &left -char &right -int &instance # Get start idx pusharg $str pusharg $left pusharg $instance call !findCharInstance &store stdlnout $store endfun fun -bool !matchStart -string &str -string &instr getstrsize $instr &store pusharg $str pusharg 0 pusharg $store call !mid &store equal $store $instr &store return $store endfun fun -int !findStringInstance -string &str -string &instr -int &instance getstrsize $instr &len subtract $len 1 &len set &idx $len @loop set &tempstr "" subtract $idx $len &tempidx subtract $tempidx 1 &tempidx @subloop equal $tempidx $idx &store if $store %continue add $tempidx 1 &tempidx getstrcharat $str $tempidx &store add $tempstr $store &tempstr jump %subloop @continue equal $tempstr $instr &store if $store %decrement add $idx 1 &idx jump %loop @decrement equal $instance 0 &store if $store %end subtract $instance 1 &instance add $idx 1 &idx jump %loop @end subtract $idx $len &idx return $idx endfun fun -string !removeLeft -string &string -int &num getstrsize $string &len set &ans "" @loop equal $num $len &store if $store %end getstrcharat $string $num &store add $ans $store &ans add $num 1 &num jump %loop @end return $ans endfun fun -string !removeRight -string &string -int &num getstrsize $string &len subtract $len $num &len set &ans "" set &num 0 @loop equal $num $len &store if $store %end getstrcharat $string $num &store add $ans $store &ans add $num 1 &num jump %loop @end return $ans endfun fun -bool !contains -string &str -string &instr getstrsize $str &len getstrsize $instr &inlen subtract $len $inlen &len set &idx 0 @loop equal $idx $len &store if $store %false pusharg $str pusharg $idx pusharg $inlen call !mid &store equal $store $instr &store if $store %true add $idx 1 &idx jump %loop @true return true @false return false endfun