StringTools
Join
join a list of strings
CaseJoin
join a list of strings, mapping each initial lowercase letter to uppercase
Calling Sequence
Parameters
Description
Examples
Join( stringList, sep )
CaseJoin( stringList )
stringList
-
list of strings; strings to join
sep
(optional) string; string separator
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→Joins,"⁢";
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.
All of the StringTools package commands treat strings as (null-terminated) sequences of 8-bit (ASCII) characters. Thus, there is no support for multibyte character encodings, such as unicode encodings.
with⁡StringTools:
L≔Split⁡This:is:a:test.,:
L≔This,is,a,test.
Join⁡L,
This is a test.
Join⁡a,b,c,
abc
CaseJoin⁡linear,algebra
LinearAlgebra
CaseJoin⁡the,cat,sat,on,the,mat.
TheCatSatOnTheMat.
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[2] = 1, sprintf( "{%d}", pp[1] ), sprintf( "{%d}^{%d}", op( pp ) ) ), F ); StringTools:-Join( S, "\\cdot" ) end proc:
TeXFactors⁡300
{2}^{2}\cdot{3}\cdot{5}^{2}
See Also
string
String
StringTools[CaseSplit]
StringTools[Split]
Download Help Document