blob: c5e39b18211cc9281ae19a08c1ebaf967b8e86bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
let drop_while predicate =
let rec _drop = function
| [] -> []
| (hd::tl) as l ->
if predicate hd then
_drop tl
else
l
in _drop
(* Split a text and and new line before it goes to long *)
let split limit =
let rec _split elms text =
let length = (String.length text) -1 in
if (length < limit) then
List.rev (text::elms)
|> String.concat "\\n"
else
try
let pos = String.rindex_from text limit ' ' in
let hd = String.sub text 0 pos
and tl = String.sub text (pos +1) (length - pos) in
_split (hd::elms) tl
with Not_found -> text
in _split []
|