StringTools - Maple Programming Help

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

StringTools

 Join
 join a list of strings
 CaseJoin
 join a list of strings, mapping each initial lowercase letter to uppercase

 Calling Sequence Join( stringList, sep ) CaseJoin( stringList )

Parameters

 stringList - list of strings; strings to join sep - (optional) string; string separator

Description

 • The Join(stringList, sep) command concatenates the ordered list of strings stringList, separated by an optional fixed string sep. If parameter sep is not included in the calling sequence, the concatenated strings are separated by a single space character. The string formed by the concatenation of the strings in stringList is returned.
 • The first calling sequence is equivalent to

$s\to \mathrm{Join}\left(s,""\right);$

 • If stringList is the empty list, then the result is an empty string. Otherwise, the strings in stringList are concatenated in order, with the separator string sep between each consecutive pair. If stringList has only one member, that member is the result string. (The separator string is used only in case there are at least two strings in stringList.)
 • The Join procedure is an approximate inverse of the Split procedure.
 • The CaseJoin(stringList) command concatenates the strings in stringList after first mapping each initial lowercase letter to uppercase. Characters that are not lowercase are not modified in the concatenated string.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $L≔\mathrm{Split}\left("This:is:a:test.",":"\right)$
 ${L}{≔}\left[{"This"}{,}{"is"}{,}{"a"}{,}{"test."}\right]$ (1)
 > $\mathrm{Join}\left(L,""\right)$
 ${"This is a test."}$ (2)
 > $\mathrm{Join}\left(\left["a","b","c"\right],""\right)$
 ${"abc"}$ (3)
 > $\mathrm{CaseJoin}\left(\left["linear","algebra"\right]\right)$
 ${"LinearAlgebra"}$ (4)
 > $\mathrm{CaseJoin}\left(\left["the","cat","sat","on","the","mat."\right]\right)$
 ${"TheCatSatOnTheMat."}$ (5)

The following procedure formats the prime factorization of a positive integer in LaTeX.

 > TeXFactors := proc( n :: posint )   local F := ifactors( n )[ 2 ];   local S := map( pp -> if( pp = 1, sprintf( "{%d}", pp ), sprintf( "{%d}^{%d}", op( pp ) ) ), F );   StringTools:-Join( S, "\\cdot" ) end proc:
 > $\mathrm{TeXFactors}\left(300\right)$
 ${"\left\{2\right\}^\left\{2\right\}\cdot\left\{3\right\}\cdot\left\{5\right\}^\left\{2\right\}"}$ (6)