[Jprogramming] learning: Having trouble writing loopless scripts

neitzel at gaertner.de neitzel at gaertner.de
Wed Aug 6 02:55:06 HKT 2008


[I'm picky here because a beginner is at risk.  I know that *I* had
troubles using "/" for my first three J years.]

Devon McCormick wrote:
>
> J has a handy adverb called "table" which is the forward slash "/".  This
> allows you to apply a function orthogonally, e.g.
>     1 2 3 4 5 +/ 1 2
> adds each number on the left to each on the right,

One might think so but this is not true.
"/" itself is not causing an "each on each".

A better wording is:

"In
	1 2 3 4 5  +/  1 2
each argument cell from the left is individually added to the entire
argument (cell array) on the right, and computation proceeds from there."

That is:

	1 2 3 4 5  +/  1 2
is computed by computing and composing the results of the five expressions
	1 + 1 2
	2 + 1 2
	3 + 1 2
	4 + 1 2
	5 + 1 2

This in turn will imply loops distributing a left cell across several (two)
right cells.   But that is not related to the "/" anymore.

								Martin


More information about the Programming mailing list