Last active
September 14, 2015 16:51
-
-
Save esehara/b19af99f2a99d2966681 to your computer and use it in GitHub Desktop.
CodeIQとかで"module Str"を使ったsplitが使えないので、自前で何とかsplitするやつを書く ref: http://qiita.com/esehara@github/items/894d8dd824b1354752f5
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
Str.split (Str.regexp_string ",") line |
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 string_separate s c = | |
let rec s_separate s c p = | |
let next_separate s p c = | |
try | |
(String.index_from s (p + 1) c) | |
with _ -> String.length s in | |
let start = p in | |
let next = next_separate s p c in | |
[String.sub s start (next - start)] @ | |
(if next < String.length s then s_separate s c (next + 1) | |
else []) in | |
s_separate s c 0;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment