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 <[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=: </.~ +/\@(-.@+._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: [email protected]
> [mailto:[email protected]] On Behalf Of Cliff Reiter
> Sent: Monday, January 26, 2015 3:46 AM
> To: [email protected]
> Subject: Re: [Jprogramming] A parsing challenge
>
>
>
> Lovely. Tiny remark:
>
>
>
>  <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,'&')>
> -.@+._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:-.@> -.@+. _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
>
> ----------------------------------------------------------------------
> 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