Skip to content

Instantly share code, notes, and snippets.

@heygema
Last active May 29, 2018 10:44
Show Gist options
  • Save heygema/30ea857f5ad04d6b2dc9aded1480bc97 to your computer and use it in GitHub Desktop.
Save heygema/30ea857f5ad04d6b2dc9aded1480bc97 to your computer and use it in GitHub Desktop.
my utils for string in ReasonML.
let split = (string) => {
let rec toList = (l, i) =>
switch (i) {
| 0 => l
| num => toList([string.[num - 1], ...l], num - 1)
};
toList([], string |> String.length)
};
let join = (charlist) => {
let rec toString = (s, i) =>
switch(i) {
| 0 => s
| num => toString((List.nth(charlist, i - 1) |> String.make(1)) ++ s, i - 1)
};
toString("", charlist |> List.length)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment