I'm not quite sure what you are saying here, but it works fine for me
without that [

Recap: func grabs a noun script as y,'_doc' with a local copy in doc,
executes the last line, and then grabs, trims, and executes the ex:
lines reporting any errors, and sticks them in y,'_examples'.

Normal use is a little repetitive - Joe's convention is that y matches
the name assigned on the last line. But that could be thought of as
good emphasis for the reader. Still, more elaborate implementation
might first erase (y) in the current locale*, then after 0 !:0 > {:
lines ensure that (y) is defined.

Thanks,

-- 
Raul

* like this:
   erase y[(y)=:0
   assert _1<<nc y

The assignment averts local and locale issues.


On Sun, Dec 6, 2015 at 11:14 AM, Brian Schott <schott.br...@gmail.com> wrote:
> Pascal (and Joe),
>
> I had noticed your witchcraft comment before and was impressed then.
> Today I noticed in another thread for day 5 of advent... where Joe
> referenced the byte code interpreter, the witch crafted definition of the
> verb func. I don't think I noticed before the leftmost verb left ([) in
> that line, perhaps because I focused on the fact the focus verb had only
> one ')' for two separate applications of definition (:). That is really
> creative and may be the reason only one ')' is required.
>
> doc=.[(y,'_doc')=: 0 : 0
>
> Btw, I tried to test out my theory of the need for the [ by redefining
> func without the [, but I was unable to exercise this new version of func
> because I could not understand how. What verb initializes all the calls
> like func '...'?
>
>
>
>
> On Fri, Nov 13, 2015 at 3:51 PM, 'Pascal Jasmin' via Programming <
> programm...@jsoftware.com> wrote:
>
>> This is some awesome witchcraft,
>>
>>
>> func=: 3 : 0
>> doc=.[(y,'_doc')=: 0 : 0
>> lines=.LF cut doc
>> 0!:0 > {: lines
>> examples=.[(y,'_examples')=:3 }. each (#~ (<'ex:') E. 3 {. each [) lines
>> assert each ". each examples
>> ''
>> )
>>
>> This is the witchcraft line
>>
>> doc=.[(y,'_doc')=: 0 : 0
>>
>> it reuses the function's own closing )
>>
>>
> --
> (B=)
> ----------------------------------------------------------------------
> 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