Roger, Raul,
Thanks. Raul's answer is essentially what I needed. And I now have Learning J 
Chapter 14 open in my browser .
I am still unsure about a few things, hopefully someone can clear these up.
1. If I have my nxn gerund array and I want to evaluate it on a list of n 
items, such that the first row takes the first item, the second row takes the 
second item etc.
e.g.  (*:`%: ,. +:`^) VRB 1 2
should evaluate to
1 14 7.38906
where VRB is some verb. Learning J, 14.3.1 has a similar example but in that 
case VRB = `:0 and it evaluateseach verb for the whole list. At first I thought 
I could do something like (`:0)"(1 0) but I still get unwanted results, namely, 
in the above case, I get 2x2x2 matrix as output. My workaround is just to take 
only the desired rows from the output.
2. This problem is a little bit more abstract. 
If I have a list of gerunds (1D this time), and I want to modify each verb in 
the gerund in some way, and then return the sum of the verbs, I am not sure how 
to do this.
For example, if G =:  *:`+:`^  and list =. 3 4 5
I want an adverb or conjunction that returns a verb of the form (3&*@:*:) + 
(4&*@:+:) + (5&*@:^) 
My attempt was to do
len =: # G output =. '' for_j i. len do. output =. output + 
((j{list)&*@:(G`:6)) end. output 
This is getting me nowhere however. I am actually not sure why it fails. One 
problem I am guessing exists is in the line output =. '' , which I used to 
'initialize' the output verb. I am unsure if this is legal though.
Regards,Jon

> Date: Sun, 19 Apr 2015 08:35:34 +0100
> From: [email protected]
> To: [email protected]
> Subject: Re: [Jprogramming] Evaluating a Gerund Array
> 
> Maybe "Learning J" section 14.3.1 might be useful.
> 
> 
> 
> On 19/04/2015 06:51, Jon Hough wrote:
> > My problem is slightly more complicated than the one I am giving in the 
> > example,but in essence the problem is, given a 2x2 array of gerunds, and 
> > anumber, how can I return a 2x2 array of the gerunds evaluated for the 
> > number.
> > e.g.
> >
> > arr =: *:`%:
> >
> >
> >
> >     arr2 =: +:`^
> >
> >
> > mat =. arr ,. arr2
> >
> >
> > list =. 4 3
> >
> >
> > I can evaluate individual cells thusly
> >
> >
> >
> >
> > ((0{0{mat)`: 6) 4
> >
> >
> > But would like a single expression that would yield the result, for example 
> > (input = 4):
> >
> >
> > 16 2
> > 8  54.5982
> >
> >
> > I cannot seem to get an expression that works. To add slightly to the 
> > complexity, my actual problem involves an
> > arbitrary nxn matrix.
> >
> >                                     
> > ----------------------------------------------------------------------
> > 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

Reply via email to