5.54 Map

• Map( <expression>, <variable>, <list> [, mode] ).
• Description: that function is a loop that build a list using the following manner: <variable> browses the elements of the <list> and for each of them, <expression> is evaluated, the function Map returns the results list. That command is the internal representation of the loop for whose usage is preferable on lisibility grounds.

The optional parameter <mode> is a complex whose default value is Nil when <mode>$=a+ib$, then:

• if $a$ is an integer and $b=0$: the elements in the <list> are handled $a$ by $a$,
• if $a$ is an integer and $b=1$: the <list> is handled by components (two components are separated with the constant jump) and the elements of each component are operated by complete packets of $a$ elements, when the jump constant is encountered in the list, it is returned in the result. An incomplete packet is not treated.
• if $a$ is an integer and $b=-1$: the <list> is treated by component (two components are separated by the constant jump) and the elements of each component are treated by complete packets of $a$ elements, when the constant jump is encountered in the list, it is not returned in the result. An incomplete packet is not treated.
• if $a=$Re(jump): the <list> is treated by component (two components are separated by the constant jump), when the constant jump is encountered in the list, it is returned in the result if $b=1$ and not returned if $b=-1$.
• Exemple(s): see the loop for for examples.
• Exemple(s): if $L$ is a variable containing a points list, then the command:
• [sum:=0, Map( Inc(sum,z), z, L), sum] returns the sum of the elements of $L$.
• the command Map(z*exp(i*$\pi$/3), z, L) returns the list of the images of the points of $L$ by the rotation : center O and angle $\pi$/3.