Thanks Henry,
Certainly more generally useful. That's going in my utility library.
Ric
> From: Henry Rich
>
> Two things:
>
> 0. sometimes you want to apply the different verbs to unboxed
> operands,
> so the boxing should be optional;
>
> 1. sometimes x and y are not the same type & so cannot be joined
>
> eachunderv=: 2 : 0
> m v 1 :(':';'x`:6&.u y')"_1 y
> :
> m v 1 :(':';'x`:6&.u&>/ y')"_1 x ,&<"_1 y
> )
> eachv =: eachunderv >
>
> eachunderv has the same spec as my 'respectively', but looks neater.
> I prefer `:6 to @.0, but it's a matter of taste.
>
> Henry Rich
>
>
> Sherlock, Ric wrote:
> > The monadic form was incorrect. Here is a working version:
> > eachv=: 1 : 0
> > m 4 :'[email protected]&.>y'"_1 y
> > :
> > m 4 :'[email protected]&.>/y'"_1 x,.y
> > )
> >
> > (<rnge) fns eachv data
> > +--------------+--------------+--------------+-------------------+
> > | 2 1 0 _1 _2| 1 2 3 4 5| 7 8 9 10 11| 3 1.5 1 0.75 0.6|
> > |11 10 9 8 7| 5 10 15 20 25|23 24 25 26 27|12 6 4 3 2.4|
> > |20 19 18 17 16| 9 18 27 36 45|39 40 41 42 43|21 10.5 7 5.25 4.2|
> > |29 28 27 26 25|13 26 39 52 65|55 56 57 58 59|30 15 10 7.5 6|
> > |38 37 36 35 34|17 34 51 68 85|71 72 73 74 75|39 19.5 13 9.75 7.8|
> > +--------------+--------------+--------------+-------------------+
> > fns eachv data
> > +--------+-------+-----------+-----------------------------+
> > | 3 2 1| 0 1| 6 7 8 9| _ 3 1.5|
> > | 9 8 7| 10 15|26 27 28 29| 4 3 2.4|
> > |15 14 13| 36 45|46 47 48 49| 3.5 3 2.625|
> > |21 20 19| 78 91|66 67 68 69|3.33333333333 3 2.72727272727|
> > |27 26 25|136 153|86 87 88 89| 3.25 3 2.78571428571|
> > +--------+-------+-----------+-----------------------------+
> >
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm