Calculemus


String Module

Explosion and implosion of strings.

Functions and values

Function or value Description

explode s

Full Usage: explode s

Parameters:
    s : string - The input string.

Returns: string list The string exploded in it single-character strings.

Converts a string into a list of single-character strings.

explode s returns the list of single-character strings that make up s, in the order in which they appear in s. If s is the empty string, then an empty list is returned.

s : string

The input string.

Returns: string list

The string exploded in it single-character strings.

Example

 explode "The Quick fox."
Evaluates to ["T"; "h"; "e"; " "; "Q"; "u"; "i"; "c"; "k"; " "; "f"; "o"; "x"; "."].

Example

 explode ""
Evaluates to [].

implode l

Full Usage: implode l

Parameters:
    l : string list - The input string list.

Returns: string The concatenation of input strings.

Concatenates a list of strings into one string.

implode [s1;...;sn] returns the string formed by concatenating the strings s1 ... sn. If n is zero (the list is empty), then the empty string is returned.

Never fails and accepts empty or multi-character component strings.

l : string list

The input string list.

Returns: string

The concatenation of input strings.

Example

 implode ["e";"x";"a";"m";"p";"l";"e"]
Evaluates to "example".

Example

 implode ["ex";"a";"mpl";"";"e"]
Evaluates to "example".

Example

 implode []
Evaluates to "".

writeToString fn

Full Usage: writeToString fn

Parameters:
Returns: string

Write from a StringWriter to a string

fn : StringWriter -> unit
Returns: string