StringTools[Map] - map a Maple procedure onto a string
StringTools[AndMap] - perform mapped disjunction over a string
StringTools[OrMap] - perform mapped conjunction over a string
|
Calling Sequence
|
|
Map(p, s)
AndMap(p, s)
OrMap(p, s)
|
|
Parameters
|
|
p
|
-
|
anything; typically, a Maple procedure to apply to string s
|
s
|
-
|
string
|
|
|
|
|
Description
|
|
•
|
The Map(p, s) function applies p to each character in string s. The mapped procedure p should map characters to characters. However, if a string of length greater than one is returned in any call to p, only the first character of the returned string is used. The mapped procedure p can return an empty string to terminate the output string at that point. The result of a call to Map is the string returned by . However, Map is more efficient.
|
|
Map is a special version of map for strings. Unlike map, extra arguments included in the call to Map are not passed to the calls to p.
|
•
|
The AndMap(p, s) function applies p to each character in string s. If p returns the value true when applied to each character of s, AndMap returns the value true. If p returns the value false when applied to any character of s, false is returned as the final result of the call to AndMap. Otherwise, AndMap returns the result FAIL.
|
|
The characters of s are visited in order and only as many characters as are needed to determine the result of AndMap are examined.
|
|
The AndMap function computes the value
|
foldl( `and`, true, op( map( p, Explode( s ) ) ) )
|
|
|
•
|
The OrMap(p, s) function applies p to each character in string s and computes the conjunction of the values of p.
|
|
The result of evaluating p at each character of s is evaluated, in order, from left to right. Each call must return one of the values true, false, or FAIL. If true is returned at any call to p, the value true is returned as the result of the call to OrMap. Otherwise, if the value FAIL is returned at any call to p, FAIL is returned as the result of the call to OrMap. Otherwise, OrMap returns the result false.
|
|
Like AndMap, the OrMap procedure tests the characters of s in order, and returns as soon as it is possible to determine the final result.
|
•
|
These functions are part of the StringTools package, and so they can be used in the form Map(..) only after executing the command with(StringTools). However, they can always be accessed through the long form of the command by using the form StringTools[Map](..).
|
|
|
Examples
|
|
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
>
|
|
| (5) |
|
|
See Also
|
|
cat, FAIL, map, seq, string, StringTools, StringTools[Capitalize], StringTools[Explode], StringTools[IsASCII], StringTools[IsUpper], StringTools[LeftFold]
|
|