module Extra:Extra definitions.sig..end
val cut : ?n:int -> string -> string listn characters of the input string (by default n=1).
Examples:
# cut "aabbc";;
: string list = ["a"; "a"; "b"; "b"; "c"]
# cut ~n:2 "aabbc";;
: string list = ["aa"; "bb"; "c"]
# cut ~n:3 "aabbc";;
: string list = ["aab"; "bc"]
val to_charlist : string -> char listcut ~n:1 but returns the list of characters (instead of strings)
of the input string. Example:
# to_charlist "aaabbc";;
: char list = ['a'; 'a'; 'a'; 'b'; 'b'; 'c']val split_old : ?d:char -> string -> string listval split : ?squeeze:bool -> ?d:char -> string -> string listsqueeze=true, which means that delimiter repetitions are considered
as single occurrences.
The empty string is converted into the empty list. Example:
# split "aaa bbb ccc";;
: string list = ["aaa"; "bbb"; "ccc"]
# split "aaa bbb ccc";;
: string list = ["aaa"; "bbb"; "ccc"]
# split ~squeeze:false "aaa bbb ccc";;
: string list = ["aaa"; ""; ""; "bbb"; "ccc"]
val merge : string -> string -> string -> stringmerge sep x y is simply equivalent to x^sep^y.
However, the partial application merge sep may be useful for defining a string list
folding (see the next section Folding and the examples in the subsection Common foldings ).val quote : ?l:string -> ?r:string -> string -> stringl (by default l="'") and a suffix r (by default r="'").val assemble : string -> string -> string -> stringval of_charlist : char list -> string# of_charlist ['h';'e';'l';'l';'o'];;
: string = "hello"
typebinop =string -> string -> string
val big : binop -> string list -> stringList.fold_left specialization:
string -> string -> stringBig when
maximum generality is requested.val merge_map : ?sep:string -> ('a -> string) -> 'a list -> stringmerge_map f l maps the function f on the list l
then merge the result with the separator (sep=" " by default).module Fold:sig..end
big constructor
in conjonction with the merge function.
val merge_fields : string -> int list -> string list -> string# merge_fields "/" [2;4] ["aaa";"bbb";"ccc";"ddd";"eee"] ;;
: string = "ccc/eee"
typeline =string
'\n'.val to_line : line -> lineStringExtra.Extra.line just adding a newline if needed.
The function StringExtra.Extra.chop may be used as inverse.
Example:
# to_line "hello";;
: line = "hello\n"
# to_line "hello\n";;
: line = "hello\n"module Text:sig..end
val chop : string -> string['\n','\t',' '].
Similar to the rstrip Python function.
Example:
# chop "hell o \t\n";;
: string = "hell o"val rstrip : string -> stringval lstrip : string -> stringStringExtra.Extra.chop but at left side.val strip : string -> stringStringExtra.Extra.chop but for both sides.