Different people may have different preferences, mine is a form that I have
used for many years and roughly corresponds to,

   fold=. {{ y (v F:. u) x}}


Thus, the example in,

Loopless Code VI: Temporary Variables (jsoftware.com)
<https://www.jsoftware.com/help/jforc/loopless_code_vi_temporary_v.htm>

becomes,

   knave=. [ ,~ \:~ @: (] }.~ [: # [)

   ( P=. 100 25 100 50 5 10 )
100 25 100 50 5 10
   ( K =. _2 ]\ 50 50 100 25 5 10 25 50 25 10 )
 50 50
100 25
  5 10
 25 50
 25 10

   K ([ (knave fold ] ) {:@:[ , ]) P
100 100 50 25 10 5  50 50
 50  50 50 25 10 5 100 25
100  50 25 25 10 5   5 10
 25  25 10 10  5 5  25 50
 50  25 10 10  5 5  25 10

I hope it helps





On Thu, Feb 25, 2021 at 7:03 PM Hauke Rehr <[email protected]> wrote:

> For labs and the wiki, we should have some examples
> easily understood. I have an example where at least
> what it does is easily understood but I won’t show
> the implementation – I did a bad job there
> Essentially, it’s $ with fill.
> Just like the other example I mentioned, {
>
>
>    2 4 7 (] F.: step)~ i.100
>  0  1  2  3  4  5  6
>  7  8  9 10 11 12 13
> 14 15 16 17 18 19 20
> 21 22 23 24 25 26 27
>
> 28 29 30 31 32 33 34
> 35 36 37 38 39 40 41
> 42 43 44 45 46 47 48
> 49 50 51 52 53 54 55
>
>
> 56 57 58 59 60 61 62
> 63 64 65 66 67 68 69
> 70 71 72 73 74 75 76
> 77 78 79 80 81 82 83
>
> 84 85 86 87 88 89 90
> 91 92 93 94 95 96 97
> 98 99  0  0  0  0  0
>  0  0  0  0  0  0  0
>
>
> Am 25.02.21 um 17:51 schrieb Eric Iverson:
> > I am a member of the silent majority on this issue.
> >
> > I have been pleased with the civility of the fold discussion considering
> > how emotional language issues can be.
> >
> > J is not designed by vote or committee. There are always going to be
> strong
> > disagreements. But we are a small community and are best served by, at
> the
> > appropriate time, burying those disagreements and moving on. I think that
> > time has come for fold.
> >
> > J is the better for having fold. Let's focus now on using it and sharing
> > how it can be used. Some labs or wiki pages would be nice!
> >
> >
> >
> >
> > On Thu, Feb 25, 2021 at 11:25 AM Hauke Rehr <[email protected]>
> wrote:
> >
> >> Good point about the silent ones: you’re right, I guess.
> >>
> >> I still disagree regarding fold being used the way you tell us.
> >> What you want to do can be done with / and the likes.
> >> Again, the main advantage of the fold verbs from my pont of view
> >> is that there may be any kind of initial data processed by v
> >> in a way given by x’s items’ values.
> >>
> >> But let’s just settle on “we agree to disagree” – I don’t think
> >> further back and forth will lead us somewhere.
> >>
> >> (and maybe I need to get some rest ere I write more rubbish here)
> >>
> >> Hauke
> >>
> >> Am 25.02.21 um 17:19 schrieb 'Sergey Kamenev' via Programming:
> >>> I think Henry Rich is most likely a genius programmer.
> >>>
> >>> By the way, I am a supporter of meritocracy,
> >>> when the weight of a person's voice depends on his merits.
> >>>
> >>> But a programming language is written for the community.
> >>> And so the voice of the community when discussing new features
> >>> should carry a lot of weight.
> >>>
> >>> The definition of a fold itself implies that there is an array that
> will
> >>> fold.
> >>> However, the initial value does not have to be an array,
> >>> but what is collapsed arg must be an array.
> >>>
> >>> Right argument have more arrayness in comparing with left arg.
> >>>
> >>> The silent majority most likely does not use Fold verbs,
> >>> therefore they are silent, since this topic does not concern them.
> >>>
> >>> Sergey.
> >>> ----------------------------------------------------------------------
> >>> For information about J forums see http://www.jsoftware.com/forums.htm
> >>
> >> --
> >> ----------------------
> >> mail written using NEO
> >> neo-layout.org
> >>
> >> ----------------------------------------------------------------------
> >> For information about J forums see http://www.jsoftware.com/forums.htm
> >>
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
>
> --
> ----------------------
> mail written using NEO
> neo-layout.org
>
> ----------------------------------------------------------------------
> 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