Thomas wrote: " I have not found any elegant way to recreate the old way of distributing a verb across a gerund except by hand.
(+:e)`(*:e)`(%e)/. 1 2 3 " See the following in the context of: http://www.jsoftware.com/pipermail/programming/2013-March/031883.html Here there are some wicked tacit solutions but not for the faint of heart... :) First let us strengthen the box spell to allow casting back, (] -: ]&.: ( box=. (< o evoke&6"0) :. (, o (tie&'' o >"0)) )) (v0`v1`v2) NB. box (monadic verb) with obverse 1 Now we can cast some spells... over=. e (&.: box) NB. (adv) ( boxat=. (box <`'')&(>x at ]) ) o evoke&6 (v`'') NB. boxat (monadic verb) takes a verb (v) and produces a verb (<@:v) <@:v ((boxat over ) (+:`*:`-:`%:))/. <@:+:`(<@:*:)`(<@:-:)`(<@:%:)/. ((boxat over ) (+:`*:`-:`%:))/. 1 2 3 4 ┌─┬─┬───┬─┐ │2│4│1.5│2│ └─┴─┴───┴─┘ or, ba=. <@: ( vac o ar 'ba' ) o evoke&6 (v`'') NB. ( vac o ar 'ba' ) (monadic verb) takes a verb (v) and produces a verb (<@:v) <@:v ((( vac o ar 'ba') over ) (+:`*:`-:`%:))/. 1 2 3 4 ┌─┬─┬───┬─┐ │2│4│1.5│2│ └─┴─┴───┴─┘ ((( vac o ar 'e' ) over ) (+:`*:`-:`%:))/. 1 2 3 4 ┌───┐ │2 │ ├───┤ │4 │ ├───┤ │1.5│ ├───┤ │2 │ └───┘ or, ((<`'') (<x at over ]) (+:`*:`-:`%:)) /. <@:+:`(<@:*:)`(<@:-:)`(<@:%:)/. ((<`'') (<x at over ]) (+:`*:`-:`%:)) /. 1 2 3 4 ┌─┬─┬───┬─┐ │2│4│1.5│2│ └─┴─┴───┴─┘ ((+:`*:`-:`%:) ([ under over <y)(>`'')) /. +:&.>`(*:&.>)`(-:&.>)`(%:&.>)/. ((+:`*:`-:`%:) ([ under over <y)(>`'')) /. 1 2 3 4 ┌───┐ │2 │ ├───┤ │4 │ ├───┤ │1.5│ ├───┤ │2 │ └───┘ or, (<`'') slashdot o (<x at over ]) (+:`*:`-:`%:) 1 2 3 4 ┌─┬─┬───┬─┐ │2│4│1.5│2│ └─┴─┴───┴─┘ (+:`*:`-:`%:) slashdot o ([ under over <y)(>`'') 1 2 3 4 ┌───┐ │2 │ ├───┤ │4 │ ├───┤ │1.5│ ├───┤ │2 │ └───┘ or, we could even spell a (tricky) verb, (tricky ((vac o ar 'ba') f.)`(+:`*:`-:`%:))/. 1 2 3 4 ┌─┬─┬───┬─┐ │2│4│1.5│2│ └─┴─┴───┴─┘ (tricky ((vac o ar 'e' ) f.)`(+:`*:`-:`%:))/. 1 2 3 4 ┌───┐ │2 │ ├───┤ │4 │ ├───┤ │1.5│ ├───┤ │2 │ └───┘ Before the task was finding a tacit solution to challenging metaprogramming problems; now the task often seems to be reduced to choosing between a variety of wicked tacit solutions. On Wed, Jan 23, 2013 at 4:29 PM, Thomas Costigliola <[email protected]>wrote: > On Wed, Jan 23, 2013 at 4:05 PM, bob therriault <[email protected] > >wrote: > > > Nice Thomas, > > > > I had not thought of oblique. > > > > You can still do this, although it is clunkier: > > > > <@(+:`*:`%/.) 3 4 5 > > +---+ > > | 6| > > | 16| > > |0.2| > > +---+ > > > > I was hoping to box each row as you attempted below... > > > > <@(+:`*:`%/."0) 3 4 5 > > +-+-+--+ > > |6|8|10| > > +-+-+--+ > > > > or better, > > > > +:`*:`%/. each 3 4 5 NB. each is &.> > > +-+-+--+ > > |6|8|10| > > +-+-+--+ > > > > > > > ... but these don't work correctly. If you look at the output it doesn't > match your first example. +:`*:`%/. applies at rank zero, so each > application applies the whole gerund to just one item, the result being > only the first gerund gets executed each time. > > I have not found any elegant way to recreate the old way of distributing a > verb across a gerund except by hand. > > (+:e)`(*:e)`(%e)/. 1 2 3 > ┌────────┐ > │2 │ > ├────────┤ > │4 │ > ├────────┤ > │0.333333│ > └────────┘ > > > Cheers, bob > > > > On 2013-01-23, at 12:51 PM, Thomas Costigliola wrote: > > > > > <@(+:`*:`%)/. 3 4 5 > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
