left-associative iterator for strings - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Iterators : StringTools/LeftFold

StringTools[LeftFold] - left-associative iterator for strings

StringTools[RightFold] - right-associative iterator for strings

Calling Sequence

LeftFold( p, id, s )

RightFold( p, id, s )

Parameters

p

-

anything; typically, a Maple procedure to iterate over string s

id

-

anything; initial value

s

-

Maple string

Description

• 

The LeftFold(p, id, s) function iterates procedure p over string s, composing the successive results from the left with the initial value id.

  

If s is the string argument abcde, then the value of the expression LeftFold( F, id, s ) is Fe,Fd,Fc,Fb,Fa,id.

  

Except for a more efficient implementation, this procedure is equivalent to the composition foldlp,id,seqt,t=s.

• 

The RightFold(p, id, s) function iterates procedure p over string s, composing the successive results from the right with the initial value id.

  

Except for a more efficient implementation, this procedure is equivalent to the composition foldrp,id,seqt,t=s.

• 

These functions are part of the StringTools package, and so they can be used in the form LeftFold(..) 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[LeftFold](..).

Examples

withStringTools:

LeftFoldcat,``,abcde

edcba

(1)

LeftFolda,b→opb,a,,abcde

a,b,c,d,e

(2)

RightFoldcat,``,abcde

abcde

(3)

RightFolda,b→opb,a,,abcde

e,d,c,b,a,

(4)

See Also

cat, foldl, foldr, op, seq, string, StringTools, StringTools[AndMap]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam