Home    Reference > C Tags > @x:for
prev next

Description

This command repeatedly execute its body under the control of an iterator.

Command Syntax

'@x:for' <for ids> ':=' <exp>
<for ids> ::= <id>
<for ids> ::= '[' {<id> ','}* <id> ']'

No options are permitted.

Name Semantics

The for <id>'s are declared the scope that surrounds the @x:for command.

Execution Semantics

A for command of the form
   @x:for i := iter { b(i}
is equivalent to
   @x:block {
      @x:func sys:Body(i) {b(i)}
      iter(sys:Body)
   }

A for command of the form
   @x:for [i,j] := iter { c(i,j}
is equivalent to
   @x:block {
      @x:func sys:Body(i,j) {c(i,j)}
      iter(sys:Body)
   }

Examples


   @x:for i := 1..10 {
      i"=>"f(i)
   }


   @use library:iterator;
   @x:for [i,j] := Nest[1..3,1..2] {
      "<&i;,&j;>&eol;"
   }


   @use library:iterator;
   @x:for i := First[Filter[iter,p]] {
      "found:"i
   } @x:else {
      "not found"
   }