It is not some deep mysterious concept.
For example:
sumvector=: 3 : 0
z=. 0
for_i. i.#y do. z=. z+i{y end.
z
)
I have written verb "sumvector" that finds the
sum of a vector:
sumvector 1 2 3 4 5
15
Now suppose I want to find the sums of a bunch
of vectors:
x=: 2 3 7 [EMAIL PROTECTED] 10
x
0 7 8 9 2 2 5
5 5 3 8 0 0 5
9 6 4 0 6 4 9
8 5 7 4 0 1 2
7 9 3 2 1 2 9
5 3 9 6 9 0 6
All I have to say is:
sumvector"1 x
33 26 38
27 33 38
When I wrote "sumvector" I did not have to give
any thought to how it's going to apply to higher
ranked arguments, because sumvector"1 is going to
do the trick.
----- Original Message -----
From: Terrence Brannon <[EMAIL PROTECTED]>
Date: Friday, April 13, 2007 8:58 am
Subject: [Jgeneral] "J for C Programmers" - verb rank independent of noun
shape
> < quote
> href=http://www.jsoftware.com/help/jforc/starting_to_write_in_j.htm >
> You give the verb the rank of the cells it operates on, and then you
> don't care about the shape of the operand, because J's implicit
> looping will apply the verb to all the cells, no matter how many there
> are.
> < / quote >
>
> Somehow, I did not capture this as an understanding from the previous
> section. The verb rank is compared to the noun rank(s) to determine
> what r-cell will be used. Then the r-cell dictates what frame will be
> chosen to make lists of r-cells. Some examples supporting this
> statement would be appreciated.
>
> < quote
> href=http://www.jsoftware.com/help/jforc/starting_to_write_in_j.htm >
> A pleasant side effect of this way of coding is that the verbs you
> write can be applied to operands of any shape: write a verb to
> calculate the current value of a loan, and you can use that very verb
> to calculate the current value of all loans at a branch, or at all
> branches in the city, or all over the state.
> < / quote >
>
> I'm sure that some later examples will show this fantastic
> scalability, so I won't ask for any now.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm