On 10/28/05, Darren Duncan <[EMAIL PROTECTED]> wrote:
> One thing I would like to be able to do is this:
>    @baz = cross([1,2],[3,4]); # yields ([1,3],[1,4],[2,3],[2,4])
> And alternately, this:
>    for cross([1,2],[3,4]) -> $foo,$bar { ... } # loop has 4 iterations

I already proposed this in this thread:


Where I called it "outer".  Nowadays, instead of returning arrays, it
probably returns tuples:

    for outer(1,2 ; 3,4) -> :($foo, $bar) {...}

So that it can be well-typed[1].

> On the other hand, perhaps something I actually want is something
> like the hyper-operation but with appropriately different syntax:
>    ['a','b'] >>~<< ['c','d']

This was also discussed.  The hot syntax at the time was:

    ('a','b') <<~>> ('c','d')

But we decided against it for a reason I can't recall at the moment.

For this, do:

    map -> :($a, $b) { $a ~ $b } outer(<a b> ; <c d>)

Perhaps this could be written:

    map &infix:<~>, *<<outer(<a b> ; <c d>)

But perhaps not.


[1] That is, if you had:

    for outer(1,2 ; "foo", "bar") -> :($foo, $bar) {...}

The compiler could be sure that $foo is a Num and $bar is a Str.

Reply via email to