String library

August 19, 2024 ยท View on GitHub

Source: include/stdlib/string.ml

Provides a functional-like ML frontend of the sds c library. The functions behave like pure ones.

Check out sds, the string library couldn't be made possible without without this c library.

Aliases

AliasAlias of
strsds

Functions

FunctionDescription
strCreates a new string starting from a null terminated C string
str_fromCreates a new string starting from a printf-alike format specifier
empty_strCreates an empty (zero length) string
extendExtends the string to the given length
cloneDuplicates the given string
clearClears the given string (in-place)
copyCopies one string to the other
lenReturns the length of the string
substrReturns the substring pointed by the indices
concatAppend the latter string to the first
concat_fromAppend the string obtained from a format specifier to the first
trimRemove the part of the string from left and from right composed just of chars found in the second c string
compareCompare two sds strings s1 and s2 with memcmp
to_lowerApply tolower to every character of the string
to_upperApply toupper to every character of the string
findReturns the index of the first occurence of sub in s
splitSplit a string with the given separator. Returns an array of strings
joinJoins an array of C strings using the specified separator and returns the result
to_strCreates strings from different types

Macros

MacroDescription
c_strConverts the argument to a c string using cast

Warnings

Warning

Functions of sds c library are not pure, unlike their ML counterparts.

Warning

Relies on the sds bindings for ML (string-backend.ml).