// Removes all whitespace characters // from the left start of a given string. def ltrim(s) do i = 0 while isWhitespace(s[i]) and i < len(s) do i = i + 1 end out = "" while i < len(s) do out = out + s[i] i = i + 1 end out end // Removes all whitespace characters // from the right start of a given string. def rtrim(s) do i = len(s) - 1 while isWhitespace(s[i]) and i > 0 do i = i - 1 end out = "" j = 0 while j <= i do out = out + s[j] j = j + 1 end out end // Removes all whitespace characters // from the left and right of a given string. def trim(s) do s |> ltrim() |> rtrim() end // Splits a given string at some delimiter. // Returns a list of strings. def split(s, delim = " ") do out = [] curr = "" for c in s do if c == delim do push(out, curr) curr = "" else curr = curr + c end end if curr != "" do push(out, curr) end out end