Closed cdaringe closed 3 years ago
Ah, sorry for the confusion. Base does offer the function you are looking for, but it's called String.to_list
rather than String.to_char_list
. There is a weird asymmetry in the name because String.of_char_list
is named in analogy to String.of_char
instead of just being called of_list
.
problem
On the concerns of exploding/imploding of strings, Base is asymmetric in that it only offers 1D of utility when breaking-up/pulling-together char lists. That is,
String.of_char_list
exists, butString.to_char_list
does not.String.split_on_chars
is nice, but is intrinsically lossy and doesn't allow to split on the empty string.Instead, users must opt to author their own impl of
string -> char list
, a lalet explode s = List.init (String.length s) (String.get s)
.discussion
Kindly consider improving the dev-ux and discoverability of the String module by adding some API symmetry on the char associated APIs. Specifically, please consider
String.to_char_list
, orChar.to_list s
, etc