On Sun, 27 Oct 2002 [EMAIL PROTECTED] wrote:
: Damian Conway wrote: 
:  : >   or
:  : > 
:  : >   given ( "/home/temp/", $f )
:  : >      -> ( str $x ,   int $n ) {
:  : >          $x ~ ["one, "two", ... , "hundreed"][$n]
:  : >         };
:  : >  
:  : >   it seems that the last does not work because given take only one argument.
:  : 
:  : That's right. But this does:
:  : 
:  :      for "/home/temp/",   $f
:  :       ->   str $x ,     int $n {
:  :             $x ~ ["one, "two", ... , "hundreed"][$n]
:  :      }
:  : 
:  : Damian
: 
: except that it will not tolerate list in block signature 
: 
:       for "/home/temp/",      @f
:         ->   str $x ,     int @y {
:                        ...
:        }
: 
: am I right ? 

"for" is special in that it provides a list context to its, er,
list, while looking for scalars in the signature to map it against.
So the problem with that example is not the signature, which nicely
specifies a scalar reference to an array, but that the list context
would naturally flatten @f.  You'd have to pass it as \@f, unless
you actually mean @f to contain a list mapping to:

    (Array of int, (str, Array of int) is repeated).

: Now it will be 
:   
:       given ["/home/temp/",   @f    ]
:         ->  [ str $x ,     int @y   ]{
:                        ...
:        }
: 
: ? 

Though that doesn't iterate like "for" can:

      for "/home/temp/",      \@f,
          "/home/notsotemp",  \@g,
        ->   str $x ,     int @y {
                       ...
      }

Larry

Reply via email to