The f11 script for running a multiline definition from anywhere inside the
enclosing code is also pretty cool
0. for (0 {:: ]) 1. for (1 {:: ]) is a big convenience to me too. 0.~ is (0
{:: [)
but quoteless code is the big feature. It makes it much easier to use custom
parsers. Gerunds specifically are easier to input with a higher priority than
conjunction separator (Q uses ; the way gg uses ` as separator)
It should be compatible with existing code as well. The one caveat is that
"fancy" multiline code (hides a (: 0) ) should use the magic constant ML so the
parser can know it is multiline. or modify the nummultiline verb.
it already handles code lines such as
3 : 0 : (4 : 0) NB. 2 multiline closing ) are needed.
As to question on continuations, it is based closely on
http://code.jsoftware.com/wiki/Guides/Lexical_Closure
but with the option of being fully anonymous. Still currently a toy.
One neat feature in the toy unrelated to closures/continuations is SNR - self
name reference. This allows genericity in having a function return a function
of itself.
A function "should"/may return a new function and a result. The best example
in the toy is
mycycle
┌───────────────────────────────────┬──┐
│┌───────────────┬───────────┬─────┐│11│
││┌─┬───────────┐│cycle_base_│┌─┬─┐││ │
│││0│10 11 12 13││ ││0│2│││ │
││└─┴───────────┘│ │└─┴─┘││ │
│└───────────────┴───────────┴─────┘│ │
└───────────────────────────────────┴──┘
This contains 2 items. A gerund representing a function, and the last result
cont2 'mycycle'
12
cont2 'mycycle'
13
these return the function result but also updates the function
mycycle
┌───────────────────────────────────┬──┐
│┌───────────────┬───────────┬─────┐│13│
││┌─┬───────────┐│cycle_base_│┌─┬─┐││ │
│││0│10 11 12 13││ ││0│0│││ │
││└─┴───────────┘│ │└─┴─┘││ │
│└───────────────┴───────────┴─────┘│ │
└───────────────────────────────────┴──┘
cycle_base_ is a dyad returns a gerund, and result, but the gerund in mycycle
has both parameters bound to it.
cycle SNR4.: (x FNAME aar tiD ((#x) | >: y) tiD ) ,&< (y{x)
the .: glyph quotes both left and right params (until any terminating ")" or
end if none found)
SNR expands the definition to
cycle
4 : 0
FNAME =. 'cycle_base_'
( x FNAME aar tiD ( ( # x ) | >: y ) tiD ) , & < ( y { x )
)
It rotates through x items.
Real applications include lazy data structures. Functions that feed one data
item at a time can work identically with a file or slow-result socket
connection, or terminate after the right result found. Anonymous and classless
versions of this process means there's nothing to cleanup when you stop
querying the next value(s).
________________________________
From: Jose Mario Quintana <[email protected]>
To: Programming forum <[email protected]>
Sent: Wednesday, March 22, 2017 4:16 PM
Subject: Re: [Jprogramming] introducing j plus plus
A quoteless J? That is neat, I do not like quoting code particularly when
it leads to quotes within quotes within quotes within...
I find the related continuations.ijs script intriguing. Can you explain
what is the purpose of the continuations? How can you use them? Simple
examples would be appreciated.
On Fri, Mar 17, 2017 at 9:25 PM, 'Pascal Jasmin' via Programming <
[email protected]> wrote:
> A preparser for J that autocloses parentheses, and makes embedding quotes
> easier. Also has user-defined primitives.
>
>
> https://github.com/Pascal-J/jpp
>
> as examples,
>
> 4 timespacex: +/ i.1000
>
> is equivalent to
>
> 4 timespacex '+/ i.1000'
>
> the suggested F11 macro is pretty neat. Runs a section of code in a
> file. Unlike ctrl-R, you don't need to be at the top level line in order
> to run the multiline group that encloses the current line.
> ----------------------------------------------------------------------
> 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