Now run the latest code again, and you will see the tacit version of Pascal's 
code.

 

]T=:  ;:'4&count int 3 8&inrange'

┌─┬─┬─────┬───┬───┬─┬───────┐
│4│&│count│int│3 8│&│inrange│
└─┴─┴─────┴───┴───┴─┴───────┘

   fpj=: 13 :'y </.~ +/\ t * _1 |. t=. y ~: <,''&'''

   fpj T

┌───────────┬─────┬───────────────┐
│┌─┬─┬─────┐│┌───┐│┌───┬─┬───────┐│
││4│&│count│││int│││3 8│&│inrange││
│└─┴─┴─────┘│└───┘│└───┴─┴───────┘│
└───────────┴─────┴───────────────┘

   

   

   

   

   ]T=:  ;:'4&count int 3 8&inrange'

┌─┬─┬─────┬───┬───┬─┬───────┐
│4│&│count│int│3 8│&│inrange│
└─┴─┴─────┴───┴───┴─┴───────┘

   fpj

] ([ </.~ [: +/\ ] * _1 |. ]) (<,'&') ~: ]

   fpj T

┌───────────┬─────┬───────────────┐
│┌─┬─┬─────┐│┌───┐│┌───┬─┬───────┐│
││4│&│count│││int│││3 8│&│inrange││
│└─┴─┴─────┘│└───┘│└───┴─┴───────┘│
└───────────┴─────┴───────────────┘

   .  

At this points there are two paths. One is my route to Simple J, I’d like to 
remove &

 

A second route is to enhance with all the newest code, with @  @: &  &. and any 
special code as well. Also improvements on speed and storage requirements could 
be addressed 

.

Linda

 

 

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Wednesday, January 28, 2015 3:28 AM
To: [email protected]
Subject: Re: [Jprogramming] A parsing challenge

 

Both Raul and Pascal responded to this challenge.  My suggestion now is that 
answers show the whole story

 

 

 

 

 

 

 

Here are Raul and Pascal's latest answers to the problem. They appear in 
context with data, verb and result.

 

]T=:  ;:'4&count int 3 8&inrange'

 

┌─┬─┬─────┬───┬───┬─┬───────┐

│4│&│count│int│3 8│&│inrange│

└─┴─┴─────┴───┴───┴─┴───────┘

 

   frm=: 13 :'y </.~ +/\ t * _1 |. t=. y ~: {.;:''&'''

 

   frm T

 

┌───────────┬─────┬───────────────┐

│┌─┬─┬─────┐│┌───┐│┌───┬─┬───────┐│

││4│&│count│││int│││3 8│&│inrange││

│└─┴─┴─────┘│└───┘│└───┴─┴───────┘│

└───────────┴─────┴───────────────┘

 

   

 

   ]T=:  ;:'4&count int 3 8&inrange'

 

┌─┬─┬─────┬───┬───┬─┬───────┐

│4│&│count│int│3 8│&│inrange│

└─┴─┴─────┴───┴───┴─┴───────┘

 

   fpj=: 13 :'y </.~ +/\ t * _1 |. t=. y ~: <,''&'''

 

   fpj T

 

┌───────────┬─────┬───────────────┐

│┌─┬─┬─────┐│┌───┐│┌───┬─┬───────┐│

││4│&│count│││int│││3 8│&│inrange││

│└─┴─┴─────┘│└───┘│└───┴─┴───────┘│

└───────────┴─────┴───────────────┘

 

   

 

As futher answers are formulated thay can be inserted and as you read future 
changes you will see how the story is developing. Copy the current ersion to a 
script and he copy a second version and insert your changes.  I think it will 
help readers to know more quickly where each thread is going.

 

 

Linda

 

 

 

 

 

-----Original Message-----

From:  <mailto:[email protected]> 
[email protected] [ 
<mailto:[email protected]> 
mailto:[email protected]] On Behalf Of 'Pascal Jasmin' 
via Programming

Sent: Tuesday, January 27, 2015 2:42 PM

To:  <mailto:[email protected]> [email protected]

Subject: Re: [Jprogramming] A parsing challenge

 

 

as you know there is 13 :

 

 

mean =: 13 : '(+/ y) % # y' 

 

 

is just as efficient once the definition is parsed as: +/ % #

 

 

not counting spaces it has 4 times as many characters to type after =:  There 
is a Homer Simpson machismo of quadrupling your productivity here :P

 

 

still, its a great way to start with J if it makes reading and writing easier.

 

 

some tips though, generally y can be replaced with ] if it is in an odd 
position in the train.

 

 

   13 :'y </.~ +/\ t * _1 |. t=. y ~: <,''&'''

 

] ([ </.~ [: +/\ ] * _1 |. ]) (<,'&') ~: ]

 

 

some caveats with the above, '&' is in an illegal (lefmost) position for a 
tacit train (cannot be noun) That is easily fixed by swapping it with y and 
parenthesizing it.

 

The t temporary variable is removed by starting another train within the train. 
 In this embedded train, ] will replace t (instead of y).  The only way to 
access y from the embedded train is to make it the x argument to that (which is 
what is done).  So the substitutions become the left and rightmost ] are y, as 
is the [.  The other ] are t.

 

 

an equivalent 13 : expression for dealing with the middle train

 

 

13 :'y 13 : ''x </.~ +/\ y * _1 |. y''  y ~: {.;:''&'''

 

 

the quote noise can be annoying, and there is a small parsing overhead.  
Sometimes there is no tacit result and so there is double parsing with the 
additional disadvantage of being reparsed for each item if rank is applied to 
the explicit verb.  In the case of adverbs, there is significant execution 
differences when calling adverbs in other locales.  If they return a tacit 
expression, then the adverb can use names in its own locale before returning a 
verb.  If the adverb access x or y, then it returns an explicit expression that 
will be parsed in the caller's locale, usually with broken results.  That is at 
least one reason for learning tacit code.  Many other people's code leans 
towards tacit too, perhaps only because it is more fun.

 

 

 

----- Original Message -----

 

From: Tobia Conforto < < <mailto:[email protected]> 
mailto:[email protected]>  <mailto:[email protected]> 
[email protected]>

 

To:  < <mailto:[email protected]> mailto:[email protected]>  
<mailto:[email protected]> [email protected]

 

Cc: 

 

Sent: Tuesday, January 27, 2015 1:24 PM

 

Subject: Re: [Jprogramming] A parsing challenge

 

 

I, for one, found Raul's solution an interesting challenge to decode by myself, 
purposely not looking at his explanation until I had cracked it myself.

 

 

Coming from a traditional and functional programming background, with some 
recent APL study, I find explicit definitions much easier to understand than 
J's verb trains. I still don't understand the philosophical reason why J won't 
have a nice lambda syntax, analogous to {…} in modern APL or the countless 
variations of (lambda …) or function() {…} in other languages.

 

 

It would make it easier to nest function definitions, avoid unnecessary string 
escaping, and introduce nested local (lexical) scoping, something that seems 
conspicuously missing in J to my novice eyes. I'm sure there is a reason, but I 
cannot see it yet. I get that { and } were too valuable as standalone 
characters, but then I'm sure the authors could have found a different pair of 
balanced symbols to use for this purpose, if they wanted.

 

 

 

On Tue, Jan 27, 2015 at 3:43 PM, Raul Miller < < <mailto:[email protected]> 
mailto:[email protected]>  <mailto:[email protected]> 
[email protected]> wrote:

 

 

> Are you asking for this?

 

> 

 

>    f=:13 :'y </.~ +/\ t * _1 |. t=. y ~: {.;:''&'''

 

> 

 

> Thanks,

 

> 

 

> --

 

> Raul

 

> 

 

> On Tue, Jan 27, 2015 at 4:22 AM, Linda Alvord 

 

> < < <mailto:[email protected]> mailto:[email protected]>  
> <mailto:[email protected]> [email protected]>

 

> wrote:

 

> >

 

> >

 

> > Here's a challenge:

 

> >

 

> >

 

> >

 

> > Just because @ might show up in third grade, that doesn't include 

 

> > all its little cousins like  @: & and &:

 

> >

 

> >

 

> >

 

> > To me, minimal documentation begins with the data using capital 

 

> > letters

 

> for

 

> > the name. Since F is not a verb, don't start here.

 

> >

 

> >

 

> >

 

> > F=: </.~ +/\@( < <mailto:-.@+._1&;|.)@:=&(%3c,'&')> 
> > mailto:-.@+._1&;|.)@:=&(%3c,'&')>  <mailto:-.@+._1&;|.)@:=&(%3c,'&')> 
> > -.@+._1&|.)@:=&(<,'&')

 

> >

 

> >

 

> >

 

> > Also it is a very tangled verb:

 

> >

 

> >   5!:4 <'F'

 

> >

 

> >   -- ~ --- /. ---- <

 

> >   │                   -- \ --- / --- +

 

> >   │                   │

 

> >   │                   │           -- -.

 

> > --+             -- @ -+     -- @ -+- +.

 

> >   │             │     │     │

 

> >   │     -- @: --+     L-----+     -- _1

 

> >   │     │       │           L- & -+- |.

 

> >   L- & -+       L- =

 

> >

 

> >

 

> >

 

> > Begin here with the data:

 

> >

 

> >         L- <,'&'

 

> >

 

> >    ]T=:  ;:'4&count int 3 8&inrange'

 

> >

 

> > --T-T-----T---T---T-T-------┐

 

> > │4│&│count│int│3 8│&│inrange│

 

> > L-+-+-----+---+---+-+--------

 

> >

 

> >

 

> >

 

> > Here's the challenge. Just for fun, write a single line direct

 

> definition of

 

> > F. Use simple J. You may use @ and name the verb f.

 

> >

 

> >

 

> >

 

> >

 

> >

 

> >    f=: 13 :' (direcct defn) '

 

> >

 

> >    f T

 

> >

 

> > ------------T-----T---------------┐

 

> > │--T-T-----┐│----┐│----T-T-------┐│

 

> > ││4│&│count│││int│││3 8│&│inrange││

 

> > │L-+-+------│L----│L---+-+--------│

 

> > L-----------+-----+----------------

 

> >

 

> >

 

> >

 

> > Apply f to T to get the result.

 

> >

 

> >

 

> >

 

> > That is usually enough information for sending a question to the forum.

 

> > Advanced programmers could use tacit verbs like Pascal's verb. Often 

 

> > you

 

> can

 

> > only explain these parts in words. Having a sample of your data and 

 

> > an indication of whether you are planning one or two arguments for 

 

> > your verb will help.

 

> >

 

> >

 

> >

 

> > Linda

 

> >

 

> >

 

> >

 

> >

 

> >

 

> >

 

> >

 

> > Message-----

 

> > From:  < <mailto:[email protected]> 
> > mailto:[email protected]>  
> > <mailto:[email protected]> 
> > [email protected]

 

> > [ < <mailto:[email protected]> 
> > mailto:[email protected]>  
> > <mailto:[email protected]> 
> > mailto:[email protected]] On Behalf Of Cliff

 

> Reiter

 

> > Sent: Monday, January 26, 2015 3:46 AM

 

> > To:  < <mailto:[email protected]> mailto:[email protected]> 
> >  <mailto:[email protected]> [email protected]

 

> > Subject: Re: [Jprogramming] A parsing challenge

 

> >

 

> >

 

> >

 

> > Lovely. Tiny remark:

 

> >

 

> >

 

> >

 

> >  < < <mailto:-.@> mailto:-.@>  <mailto:-.@> mailto:-.@>  < <mailto:-.@> 
> > mailto:-.@>  <mailto:-.@> -.@+. could be replaced by +:

 

> >

 

> >

 

> >

 

> > On 1/26/2015 1:00 AM, Raul Miller wrote:

 

> >

 

> >> A note of explanation...

 

> >

 

> >>

 

> >

 

> >> (I have been noticing that far too much software is poorly documented.

 

> >

 

> >> And while I cannot do an adequate job of documenting other people's

 

> >

 

> >> software, I can document software I write.)

 

> >

 

> >>

 

> >

 

> >>     F=: </.~ +/\@( < < <mailto:-.@+._1&;|.)@:=&(%3c,'&')> 
> >> mailto:-.@+._1&;|.)@:=&(%3c,'&')>  <mailto:-.@+._1&;|.)@:=&(%3c,'&')> 
> >> mailto:-.@+._1&;|.)@:=&(%3c,'&')>

 

> >  < <mailto:-.@+._1&;|.)@:=&(%3c,'&')> mailto:-.@+._1&;|.)@:=&(%3c,'&')>  
> > <mailto:-.@+._1&;|.)@:=&(%3c,'&')> -.@+._1&|.)@:=&(<,'&')

 

> >

 

> >>     T=:  ;:'4&count int 3 8&inrange'

 

> >

 

> >>

 

> >

 

> >> The first thing I do is find out where & appears:

 

> >

 

> >>     =&(<,'&') T

 

> >

 

> >> 0 1 0 0 0 1 0

 

> >

 

> >>

 

> >

 

> >> The second thing I do is rotate to the right and combine:

 

> >

 

> >>     (+. _1&|.) =&(<,'&') T

 

> >

 

> >> 0 1 1 0 0 1 1

 

> >

 

> >>

 

> >

 

> >> Except I want to mark the beginning of each section with a 1, and

 

> >

 

> >> right now they are zeros.

 

> >

 

> >>     ( < < <mailto:-.@> mailto:-.@>  <mailto:-.@> mailto:-.@>  < 
> >> <mailto:-.@> mailto:-.@>  <mailto:-.@> -.@+. _1&|.) =&(<,'&') T

 

> >

 

> >> 1 0 0 1 1 0 0

 

> >

 

> >>

 

> >

 

> >> As an aside, note that I could have cut that step out if I had 

 

> >> started

 

> >

 

> >> by identifying where & does not appear (and then combine using 

 

> >> logical

 

> >

 

> >> and instead of logical or):

 

> >

 

> >>

 

> >

 

> >>     (* _1&|.) ~:&(<,'&') T

 

> >

 

> >> 1 0 0 1 1 0 0

 

> >

 

> >>

 

> >

 

> >> Next, I use plus scan to turn my markers into keys:

 

> >

 

> >>

 

> >

 

> >>     +/\ (* _1&|.) ~:&(<,'&') T

 

> >

 

> >> 1 1 1 2 3 3 3

 

> >

 

> >>

 

> >

 

> >> Finally, I use these keys to group the original elements:

 

> >

 

> >>

 

> >

 

> >>     T </.~ +/\ (* _1&|.) ~:&(<,'&') T

 

> >

 

> >> +-----------+-----+---------------+

 

> >

 

> >> |+-+-+-----+|+---+|+---+-+-------+|

 

> >

 

> >> ||4|&|count|||int|||3 8|&|inrange||

 

> >

 

> >> |+-+-+-----+|+---+|+---+-+-------+|

 

> >

 

> >> +-----------+-----+---------------+

 

> >

 

> >>

 

> >

 

> >> And that exposition pretty much follows the thought process I

 

> >

 

> >> originally used to compose the sentence.

 

> >

 

> >>

 

> >

 

> >> Thanks,

 

> >

 

> >>

 

> >

 

> >

 

> >

 

> > --------------------------------------------------------------------

 

> > --

 

> >

 

> > For information about J forums see  

 

> > <http://www.jsoftware.com/forums.htm

 

> >

 

> >  < <http://www.jsoftware.com/forums.htm> 
> > http://www.jsoftware.com/forums.htm>  <http://www.jsoftware.com/forums.htm> 
> > http://www.jsoftware.com/forums.htm

 

 

> >

 

> > --------------------------------------------------------------------

 

> > -- For information about J forums see 

 

> >  < <http://www.jsoftware.com/forums.htm> 
> > http://www.jsoftware.com/forums.htm>  <http://www.jsoftware.com/forums.htm> 
> > http://www.jsoftware.com/forums.htm

 

> ----------------------------------------------------------------------

 

> For information about J forums see  < <http://www.jsoftware.com/forums.htm> 
> http://www.jsoftware.com/forums.htm>  <http://www.jsoftware.com/forums.htm> 
> http://www.jsoftware.com/forums.htm

 

> 

 

----------------------------------------------------------------------

 

For information about J forums see  < <http://www.jsoftware.com/forums.htm> 
http://www.jsoftware.com/forums.htm>  <http://www.jsoftware.com/forums.htm> 
http://www.jsoftware.com/forums.htm

 

----------------------------------------------------------------------

 

For information about J forums see  < <http://www.jsoftware.com/forums.htm> 
http://www.jsoftware.com/forums.htm>  <http://www.jsoftware.com/forums.htm> 
http://www.jsoftware.com/forums.htm

 

----------------------------------------------------------------------

For information about J forums see  <http://www.jsoftware.com/forums.htm> 
http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to