According to Google, HOF is:

In mathematics and computer science, a *higher*-*order function* (also
functional, functional form or functor) is a *function* that does at least
one of the following: takes one or more *functions* as arguments (i.e.,
procedural parameters), returns a *function* as its result.

That is exactly what J modifiers do.

In your example sum is created by insert (/) taking on add (+) as an
argument producing the verb sum. But your definition of scan is a verb when
it makes more sense to make it an adverb. Because is should be a HOF, not a
verb. And as it is used it is a monad, not a dyad. It could be defined as a
HOF a couple of ways.

   scan=: 1 : 'u\y'
   sum=: +/
   sum scan 1 2 3
1 3 6

or simply

   scan =: \
   sum scan 1 2 3
1 3 6

So, I'm confused. It looks like you're trying to create something that
already exists.

On Thu, Nov 23, 2017 at 6:45 AM, Alex Shroyer <[email protected]> wrote:

> Right, the closest I can come to my HOF example in standard J is:
>
>    scan =: dyad def '(x`:6)\ y'
>    sum =: +/
>    sum`'' scan 1 2 3
> 1 3 6
>
> It would be more convenient to just write 'x\y' where x is a verb, but I
> realize this would be a significant change to parsing and semantics (even
> if it's a rather minor change to syntax).
> I will check out the parser source code, maybe I can scrape together
> something for people to try out.  But please no one hold their breath. :)
>
>
> On Wed, Nov 22, 2017 at 12:05 PM, Henry Rich <[email protected]> wrote:
>
> > Single gerund:
> >
> > verb`''
> >
> > or
> >
> > {. verb`''
> >
> >
> > Henry Rich
> >
> > On 11/21/2017 6:02 PM, Daniel Lyons wrote:
> >
> >> On Nov 21, 2017, at 11:56 AM, Alex Shroyer <[email protected]> wrote:
> >>>
> >>> However, one frustration I still have is regarding explicit
> definitions.
> >>> IMO they should be replaced with something more like what the K
> language
> >>> provides, namely first-class, lexically-scoped functions:
> >>>
> >>
> >> This is a nice thing in Dyalog as well, and it has the same syntax
> there,
> >> except alpha for x and omega for y. My experience from other systems
> makes
> >> me feel that code in strings is icky, and it doesn’t syntax-highlight
> well
> >> either. On the other hand, I am still new—is it common to pass around
> >> strings bearing code? This is common in Tcl, where there are several
> ways
> >> of quoting. I don’t see an obvious way to make a gerund from a single
> >> verb—is that ever done, and are strings the secret to it?
> >>
> >>
> >
> > ---
> > This email has been checked for viruses by AVG.
> > http://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

Reply via email to