The main point I was trying to make was that F:. showed behaviour not conform the diagram on https://code.jsoftware.com/wiki/Vocabulary/fcap. The role of x and y seem to be interchanged. However, then u F:.v~ should work, which does not.
The advantage of fold is just that x can differ essentially from an item of y, contrary to /\. , where all items are equal, and you are forced to use boxes. R.E.Boss -----Original Message----- From: Programming <[email protected]> On Behalf Of Raul Miller Sent: dinsdag 7 september 2021 10:16 To: Programming forum <[email protected]> Subject: Re: [Jprogramming] Fold experience Swapping the argument does not appear to influence the shape of the result. The results themselves are different, UV=:0,(,-@|.)=i.3 foo=: {{ x+ y{UV }} oof=: {{ y+ x{UV }} 0 0 0 (]F:.foo -: ]F:.foo~) 3 2 _3 0 0 0 0 (]F:.oof -: ]F:.oof~) 3 2 _3 0 That said, focusing on the variant which you described as providing the desired behavior: 0 0 0 ]F:.oof 3 2 _3 0 0 1 0 1 1 0 1 0 This corresponds to: 3 oof 0 0 0 0 0 1 2 oof 3 oof 0 0 0 0 1 1 _3 oof 2 oof 3 oof 0 0 0 0 1 0 Which, in turn, somewhat matches the value selection mechanism of J's scan: <\ 3 2 _3 +-+---+------+ |3|3 2|3 2 _3| +-+---+------+ The difference between fold and scan being that fold reuses the result of the previous evaluation while scan does not. I hope this makes sense, -- Raul On Tue, Sep 7, 2021 at 2:09 AM R.E. Boss <[email protected]> wrote: > > [UV=:0,(,-@|.)=i.3 > > 0 0 0 > > 1 0 0 > > 0 1 0 > > 0 0 1 > > 0 0 _1 > > 0 _1 0 > > _1 0 0 > > > foo=: {{ x+ y{UV }} NB. constructed conform the diagram on > https://code.jsoftware.com/wiki/Vocabulary/fcap > > > > $0 0 0 (]F:. foo) 3 2 _3 > > 3 3 3 3 3 > > $0 0 0 (]F:. foo)~ 3 2 _3 > > 3 3 3 3 3 > > > foo=: {{ y+ x{UV }} NB. y and x are swapped, counterintuitive > > > > $0 0 0 (]F:. foo) 3 2 _3 > > 3 3 > > 0 0 0 (]F:. foo) 3 2 _3 NB. this is the desired behaviour > > 0 0 1 > > 0 1 1 > > 0 1 0 > > $0 0 0 (]F:. foo)~ 3 2 _3 > > 3 3 > > Also remarkable is that swapping the arguments seems not to influence the > result. > Any clarification? > > > R.E. Boss > > ---------------------------------------------------------------------- > 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
