Last active
May 29, 2018 10:44
-
-
Save heygema/30ea857f5ad04d6b2dc9aded1480bc97 to your computer and use it in GitHub Desktop.
my utils for string in ReasonML.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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