Hi, if I may come back to this one for a minute....

Now, I can see that is the most 'obvious' solution in terms of
computational efficiency, since
n * n-1 *...* n-r+1
is a whole lot better than 
!n % !(n-r)
and certainly what I'd be aiming for in any other language.

I can follow Ambrus' statement below, and even break it up a bit but I
can't say that I have 100% comprehension.  For, instance I can see that
that  14(-i.)3 will give 14 13 12 
(where is this documented? I also discovered [by chance] that 'n +i. m'
will give ascending ranges for integer m, n). So,
 */ 14-i.3
will give the desired result, as would '*/ 12+i.3'

Things are a little less clear when trying the full tacit implementation
Why does (*/ @ (-i.)) not behave as a fork?  It would be meaningless, of
course, since 14*/3 is 42, and 14-i.3 is 14 13 12, but 42 @ 14 13 12 is
a domain error.

So whereas I can see that the @ is applying the product to our list of
numbers, I can't quite see how it's justified in the grammar. 

My apologies for asking what a good reading of the docs would no doubt
solve, but the quality of the feedback here really accelerates learning
- that's my excuse anyway, and I'm sticking to it ;)



On Mon, 2010-02-15 at 12:55 +0100, Zsbán Ambrus wrote:
> There's a third solution by the way, which doesn't rely on the (!)
> verb, and might actually be simpler.
> 
>    14 */@(-i.) 3
> 2184
> 
> Ambrus
> ----------------------------------------------------------------------
> 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