StringTools - Maple Programming Help

Home : Support : Online Help : Programming : Names and Strings : StringTools Package : List Conversions : StringTools/Explode

StringTools

 Explode
 convert a string to a list of characters
 Implode
 convert a list of characters to a string

 Calling Sequence Explode( s ) Implode( stringList )

Parameters

 s - string stringList - list of strings

Description

 • The Explode(s) function converts string s into a list of its individual characters.
 If s is empty, then an empty list is returned. Otherwise, the list consisting of the characters comprising s, in order, is returned. Each string in the returned list has length equal to one (i.e., each string in the list is a single character string).
 This procedure is equivalent to

$\left[\mathrm{seq}\left(t,t=s\right)\right]$

 • The Implode(stringList) function is the inverse of the Explode(s) function.
 If stringList is empty, then the empty string is returned. Otherwise, the catenation of the one-character strings in stringList is returned.
 This procedure is equivalent to

$\mathrm{stringList}\to \mathrm{cat}\left("",\mathrm{seq}\left(s\left[1\right],s=\mathrm{stringList}\right)\right)$

 Note: The strings in stringList are all assumed to have length equal to one (whether this is, in fact, true or not). Only the first character of each string is used.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{Explode}\left(""\right)$
 $\left[{}\right]$ (1)
 > $\mathrm{Explode}\left("ABC"\right)$
 $\left[{"A"}{,}{"B"}{,}{"C"}\right]$ (2)
 > $\mathrm{Explode}\left("Bang Your Box"\right)$
 $\left[{"B"}{,}{"a"}{,}{"n"}{,}{"g"}{,}{""}{,}{"Y"}{,}{"o"}{,}{"u"}{,}{"r"}{,}{""}{,}{"B"}{,}{"o"}{,}{"x"}\right]$ (3)
 > $\mathrm{Implode}\left(\left[\right]\right)$
 ${""}$ (4)
 > $\mathrm{Implode}\left(\left["a","b","c"\right]\right)$
 ${"abc"}$ (5)