Oh, it's certainly doable -- it's that 'simple J' makes some things more complicated.
That said, inner product is not very complicated: mv =: ([: +/ *)"1 mm =: [: |: (mv"2 1 |:) $ (i.3 4 5)+/ .*i.5 6 7 3 4 6 7 ((i. 3 4 5) mm i.5 6 7) -: (i. 3 4 5) +/ .* i.5 6 7 |length error: mm ((i. 3 4 5) ([: +/ *)"(1 _) i.5 6 7) -: (i. 3 4 5) +/ .* i.5 6 7 1 And, my other example becomes: ([: < [: toupper >)"0 'this';'is';'a';'test' And, in general, artificially restricting vocabulary can make concepts clearer. For example, it can also be instructive to express inner product without using J's multiply verb. However, "instructive" and "simple" are not the same thing. Also, sticking with a single restriction for too long enshrines the restriction and leads attention away from the concepts that should have been learned. -- Raul On Wed, Dec 7, 2011 at 10:58 AM, Kip Murray <k...@math.uh.edu> wrote: > You have seen me escape from Simple J when the going got rough! But for > matrix multiplication you can do > > mv =: ([: +/ *)"1 NB. matrix times vector > > mm =: [: |: (mv"2 1 |:) NB. matrix time matrix > > ]a =: i. 2 3 > 0 1 2 > 3 4 5 > > ]v =: i. 3 > 0 1 2 > > a mv v > 5 14 > > ]b =: i. 3 3 > 0 1 2 > 3 4 5 > 6 7 8 > > a mm b > 15 18 21 > 42 54 66 > > a +/ . * b > 15 18 21 > 42 54 66 > > To me it is always a pleasure to see how simply J can do complicated > things. And I am glad we have +/ . * . > > > On 12/7/2011 8:02 AM, Raul Miller wrote: > > Yes, that was intended to be a simple, meaningful example of f@g@h -- > and a > > concise example of how the "Simple J" rules can make some things awkward. > > > > (But it's hardly the only thing made awkward -- consider inner product as > > another concise example.) > ... > > (THE EXAMPLE:) > > > require 'strings' NB. require needed for j6, irrelevant for j7 > > > > <@toupper@> 'this';'is';'a';'test' > > +----+--+-+----+ > > |THIS|IS|A|TEST| > > +----+--+-+----+ > > > > Here's an explicit equivalent that does not require rank and does not > use @ > > a=: toupper 0 {:: 'this';'is';'a';'test' > > b=: toupper 1 {:: 'this';'is';'a';'test' > > c=: toupper 2 {:: 'this';'is';'a';'test' > > d=: toupper 3 {:: 'this';'is';'a';'test' > > a;b;c;d > > +----+--+-+----+ > > |THIS|IS|A|TEST| > > +----+--+-+----+ > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm