Raul Miller-4 wrote:
>
> On 6/28/08, Jack Andrews <[EMAIL PROTECTED]> wrote:
>> how would you express the 'less interesting' case in J?
>
> ({.-+/@}.)1 2 3 4 5
>
>
Although this is correct in the case of -, I think the general solution to
this
problem is -~/|.1 2 3 4 5
-/1 2 3 4 5
3
-~/|.1 2 3 4 5
_13
in the following sense:
f/1 2 3 4 5 NB. evaluates as:
1 f 2 f 3 f 4 f 5
(1 f(2 f(3 f(4 f 5)))) NB. default right to left order
f~/|.1 2 3 4 5 evaluates as:
f~/5 4 3 2 1 NB. default right to left order
5 f~ 4 f~ 3 f~ 2 f~ 1
(5 f~(4 f~(3 f~(2 f~ 1)))) NB. default right to left order
(4 f~(3 f~(2 f~ 1)))f 5
((3 f~(2 f~ 1))f 4)f 5
(((2 f~ 1)f 3)f 4)f 5
(((1 f 2)f 3)f 4)f 5 NB. left to right order
--
View this message in context:
http://www.nabble.com/right-to-of-left----what-about-left-to-right--tp18155817s24193p18180713.html
Sent from the J Chat mailing list archive at Nabble.com.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm