[Jprogramming] Contrintuitive argument order in Fold right verb
Henry Rich
henryhrich at gmail.com
Sun Feb 21 20:32:08 UTC 2021
Your argument is unconvincing to me.
J generally processes right to left: agreed.
J has a principle for deciding which argument of a verb should be on the
left: the more 'control-like' argument. The right argument is more
'data-like'. You apply the control argument to the data.
Thus, (x | y) is the remainder after dividing by x, and (x u^:n y)
applies x&u to y, n times (and if n=0 you get y).
The point is that order of arguments comes from a different principle
than order of execution, and you should expect the order of arguments to
be the same regardless of the direction of the fold.
Henry Rich
On 2/21/2021 1:52 PM, 'Sergey' via Programming wrote:
> Hi!
>
> I am glad that in version 9.02 verbs are now executed from right to left,
> which corresponds to the logic of J.
>
> However, in my opinion, the order of passing arguments to the right
> verb (see_arg in my example)
> also needs to be changed for the logic of J.
>
> see_arg =: dyad : 0
> NB. See argument order
> echo x, y
> x + y
> )
>
> Today:
>
> 7 ] F:. see_arg 1 2 3 4
>
> 1 7
> 2 8
> 3 10
> 4 13
> 8 10 13 17
>
> The proposed order is more logical: left ini value goes to left
> argument and right array values going to right argument of verb:
>
> 7 ] F:. see_arg 1 2 3 4
>
> 7 1
> 8 2
> 10 3
> 13 4
> 8 10 13 17
>
> Sergey.
>
>
>
> On Sun, 21 Feb 2021 07:28:44 -0600, Julian Fondren
> <jfondren at minimaltype.com> wrote:
>
>> There's " https://code.jsoftware.com/wiki/Vocabulary/quotem
>> Common use #2, to make a constant verb out of a noun.
>>
>> (_."_)`2:`3:@.] i:2
>> 2 3 _. 2 3
>
> Hi Julian,
>
> thanks for the hint! This does exactly what I was looking for.
>
> Regards,
>
> Thomas
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
--
This email has been checked for viruses by AVG.
https://www.avg.com
More information about the Programming
mailing list