Need to fix a couple of things in your example. add is just fine, but scan,
though it may be correct in Python, needs a little work. First, scan is a
monad, not a dyad. There is no x. In J /\ gives what gets your answer in J.
So, to get the result you show it needs to be redefined as follows:

   add  =: dyad def 'x+y'
   scan =: adverb def 'u/\y'
   add scan 2 3 4
2 5 9



On Tue, Nov 21, 2017 at 12:05 PM, Raul Miller <[email protected]> wrote:

> Hmm...
>
> Two challenges here.
>
> One would be finding appropriate delimiters - for example, we might
> use (. ). and (: ): where K uses {} and [], and =: where K uses :
>
> The other would be defining suitable parsing rules. This turns out to
> be a non-trivial issue (depending on how much of K's grammar we would
> want to incorporate and how much of J's explicit definitions we would
> want to incorporate).
>
> That said, if you (or someone else) wanted to extend the parsing table
> at http://www.jsoftware.com/help/dictionary/dicte.htm to achieve this,
> I think we all might be interested in the result.
>
> (It's tempting to say "it's just another kind of string literal that
> gets handed of to an independent parser" - but if you go that route
> you have forbidden nesting these definitions, and it's probably better
> to stick with the existing approach instead.)
>
> Thanks,
>
> --
> Raul
>
> On Tue, Nov 21, 2017 at 1:56 PM, Alex Shroyer <[email protected]> wrote:
> > @AndrewD: I've been using J casually for about 2 years, and consider
> myself
> > an "intermediate beginner".  I also use Python, and my impression is that
> > Python makes it easy to see what the author *wanted* the program to do,
> but
> > J makes it easier to see what the program *actually does*.
> >
> > 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:
> >
> >    add: {x+y}
> >    scan: {x\y}
> >    scan [add; 2 3 4]
> > 2 5 9
> >
> > Perhaps J's syntax could be extended someday, to recognize this type of
> > function in an explicit definition, for example:
> >
> >    add =: dyad def 'x+y'
> >    scan =: HOF def 'x\y'  NB. in this scheme, HOF stands for
> 'higher-order
> > function' and tells interpreter to not evaluate x or y until both
> arguments
> > are bound
> >    add scan 2 3 4
> > 2 5 9
> >
> > There are a few other things I'd like J to take from K, but that's the
> big
> > one.
> >
> > On Mon, Nov 20, 2017 at 11:16 AM, chris burke <[email protected]>
> wrote:
> >
> >> Dear All
> >>
> >> My attempt to move this thread over to programming failed, but please
> note
> >> for future use that discussions like this on the language are much
> better
> >> addressed to the programming forum. Not least, they will then reach all
> J
> >> forum readers, not just those subscribed to general. See http://code.
> >> jsoftware.com/wiki/System/Forums .
> >>
> >> Thanks.
> >>
> >> Chris
> >> ----------------------------------------------------------------------
> >> 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
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to