Lovely. Tiny remark:

-.@+. 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=: </.~ +/\@(-.@+._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.
    (-.@+. _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

Reply via email to