"Larry Wall" <[EMAIL PROTECTED]> wrote: > On Thu, Dec 05, 2002 at 10:09:08AM -0800, Michael Lazzaro wrote: > : What about "divvy" (or are we already using that for something else?) > : > : my(@a,@b) = divvy { ... } @c; > > Any such solution must use := rather than =. I'd go as far as to say > that divvy should be illegal in a list context.
I'm not sure I understand that: we're assigning here, not binding (aren't we?). > Note that if the closure is expected to return a small integer saying > which array to divvy to, then boolean operators fall out naturally > because they produce 0 and 1. Only if we apply a bit of magic (2 is a true value). The rule might be: If context is an list of arrays, then the coderef is evaluated in integer context: to map each input value to an integer, which selects which array to append the input-value onto. If the size of the context is "list of 2 arrays", then the coderef is evaluated in Boolean context, and the index determined as c< $result ?? 1 :: 0 >. If the context is a single array, then it is assumed to be an array-of-arrays: and the coderef is evaluated in integer-context. If the context is a hash, then the coderef is evaluated in scalar context, and the result used as a hash key: the value is pushed onto the array, in the hash, identified by the key. One more thing: how to I tell the assignment not to clear to LHS at the start of the operation. Can I say: my (@a,@b) = divvy { ... } @a1; (@a,@b) push= divvy { ... } @a2; Dave.