[Jprogramming] Fold -- can't get it to work
Piet de Jong
pietdion at gmail.com
Thu Jul 2 20:18:56 UTC 2020
My issue is not with x and y insofar as (u F:. v) is concerned. I agree it makes sense for x to be 'control information/initial condition' and y the ’data’.
My concern is with x and y insofar as v is concerned. Each item in y for the verb (u F:. v) now becomes x for the verb v. So the data items y become x’s from v’s point of view.
Thanks for making this great addition to J (ie the conjunction F:. etc).
> On 2 Jul 2020, at 10:32 pm, Henry Rich <henryhrich at gmail.com> wrote:
>
> The J way is for x to be 'control information' and y to be 'data', so that x u^:v y is intuitive.
>
> Also, u/ processing is generally right to left through a cascade of items.
>
> Also, x is optional. y can never be optional.
>
> Putting those thoughts together, I came up with the current design. Some agree, some have complained, but not stridently enough to convince us to change it. Dissenters could get in the habit of writing (v~), perhaps.
>
> Henry Rich
>
> On 7/2/2020 3:22 AM, Piet de Jong wrote:
>> Thanks. Didn’t realise the significance of the change. Have now got it to work.
>>
>> There is a feature of F:. which I find confusing.
>>
>> The x argument to u F:. v appears to be the initial condition while the items of y (I understand) are the items to be processed.
>>
>> However insofar as v is concerned, the roles of x and y are reversed. That is each y item becomes x for v as while the result of the previous application of v is assumed to be y. Why this design?
>>
>> Isn’t it more natural to think of the result of each iteration as the new “initial condition.” (ie x) and the y for v as the next item to be processed — ie the relevant item of y as passed to (u F:. v)
>>
>> Having said that I find F:. an impressive addition.
>>
>>> On 2 Jul 2020, at 10:14 am, Henry Rich <henryhrich at gmail.com> wrote:
>>>
>>> Fold changed in 9.02, reversing the meaning of u and v. You have 9.01 and are expecting the old interpretation. NuVoc is for 9.02 (it has a note to that effect IIRC).
>>>
>>> Henry Rich
>>>
>>> On 7/1/2020 7:29 PM, Piet de Jong wrote:
>>>> Started looking at fold — seems a very useful new verb.
>>>> However couldn’t get it to work
>>>>
>>>> Engine: j901/j64avx2/darwin
>>>> Release-e: commercial/2020-01-29T12:41:32
>>>> Library: 9.01.21
>>>> Qt IDE: 1.8.6/5.12.7(5.12.7)
>>>> Platform: Darwin 64
>>>> Installer: J901 install
>>>> InstallPath: /applications/j901
>>>>
>>>> Here is the what happens when I run the example from the vocabulary
>>>>
>>>> u
>>>> 3 : 0
>>>> z=. -y
>>>> z [smoutput ' u' ; y ; '-->' ; z
>>>> )
>>>> v
>>>> 4 : 0
>>>> z=. y + 0.01
>>>> z [smoutput x ; 'v' ; y ; '-->' ; z
>>>> )
>>>> y
>>>> 100 0.1 1.1 2.1 3.1
>>>> u F:.v y
>>>> |domain error
>>>> | u F:.v y
>>>>
>>>> Any help much appreciated.
>>>>
>>>>
>>>> ----------------------------------------------------------------------
>>>> 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
>>>
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list