Tokenize a string: Difference between revisions

Content added Content deleted
(added ocaml)
Line 290: Line 290:
Str.split (Str.regexp_string sep) str</ocaml>
Str.split (Str.regexp_string sep) str</ocaml>


There is already a library function for joining:
Joining is a simple folding recursion:
<ocaml>String.concat sep strings</ocaml>
<ocaml>let rec join_with d = function
[] -> ""
| [x] -> x
| x :: xs -> x ^ d ^ join_with d xs</ocaml>


=={{header|Perl}}==
=={{header|Perl}}==