parse - luxembourg/muxcode-clm GitHub Wiki

ITER() PARSE()

FUNCTION: iter(<list>,<eval>[,<input delim>[,<output delim>]]) parse(<list>,<eval>[,<input delim>[,<output delim>]])

<list> is a <input delim>-separated list of strings (e.g., A B C). <eval> is a string that is to be evaluated once for each item in <list> replacing the special symbol ## with the corresponding item from <list> and the symbol #@ with the position within the list being iterated. Remember that <eval> is evaluated after ## and #@ are substituted. For this reason, itext() is preferred over ##, and inum() is preferred over #@.

An <output delim>-separated list of the results of these evaluations is returned to the caller. The effect is very similar to @dolist except that the results are made into a list and returned instead of executed.

In addition to any single character, <output delim> can also be the null- delimiter, @@, or a newline, %r. By default, input and output delimiters are both space.

Examples: > say iter(This is a test,strlen(##)) You say, "4 2 1 4" > say iter(lnum(10),mul(mul(##,##),10)) You say, "0 10 40 90 160 250 360 490 640 810" > say iter(lcon(me),[name(##)]..[money(##)]) You say, "test..1 t1..1 radio..1 The Wizard's Pointy Hat..1" > say iter(Was it a cat I saw,[words(##)] #@,s) You say, "1 1 4 2 1 3"

Related Topics: @dolist, ilev, inum, itext, list, step