package fmlib

  1. Overview
  2. Docs

Module Fmlib_std.StringSource

A small wrapper around Stdlib.String with some extra functions.

Use Stdlib.String if you need functions from the ocaml standard library which are not in this module.

Sourcetype t = string

A standard ocaml string.

Sourceval is_prefix : t -> t -> bool

is_prefix a b Is a a prefix of b?

Sourceval is_suffix : t -> t -> bool

is_suffix a b Is a a suffix of b?

Sourceval reverse : t -> t

reverse s reverses the string s.

Sourceval compare : t -> t -> int

compare s1 s2 Compare the strings s1 and s2.

Return -1, if s1 is lexicographically smaller than s2 Return 0, if both string are equal Return +1, if s1 is lexicographically greater than s2

Sourceval one : char -> t

one c A string with the character c as the only character.

Sourceval find : (char -> bool) -> int -> t -> int

find p start str Find the position of the first character starting from start in the string str which satisfies the predicate p. If no character can be found return the length of the string.

Sourceval has : (char -> bool) -> int -> t -> bool

has p start str Does the string str starting from position start have a character satisfying the predicate p?

Sourceval find_bwd : (char -> bool) -> int -> t -> int

find_bwd p beyond str Find the position of the first character before beyond in the string str which satisfies the predicate p. Return -1, if no character can be found.

Sourceval list : t -> char list

list str Convert the string str to a list of characters.

Sourceval of_list : char list -> t

of_list l Convert the list l of characters to a string.

Sourceval length : t -> int

length str The length of the string str.

Sourceval get : t -> int -> char

get str i The ith character of the string str.

Precondition: 0 <= i && i < length str

Sourceval sub : t -> int -> int -> t

sub str start len The substring of str starting at start with length len.

Precondition: 0 <= start <= start + len <= length str

Sourceval concat : string -> string list -> string

concat sep str_list Concatenate the strings in the string list str_list and put the separator sep between them.

Sourceval split_on_char : char -> string -> string list

split_on_char c str Split the string str on each occurrence of the character c into a list of strings.

Sourceval make : int -> char -> t

make n c Make a string with n copies of the character c.

Sourceval init : int -> (int -> char) -> t

init n f Make a string of length n where the ith character is f i.

Sourcemodule To_source : sig ... end

Conversion of a string to a source of characters.

Sourcemodule From_source (S : Interfaces.SOURCE with type item = char) : sig ... end

Conversion of a source of characters to a string.

OCaml

Innovation. Community. Security.