For documentation you can do
defdeltb =: 1 : 0
...
)
and
deltb =: ''defdeltb
Then typing
defdeltb
provides documentation, as typing EXPLAIN does in an APL workspace.
Sherlock, Ric wrote:
>> From: david alis
>>
>> While looking for a J equivalent I ended up
>> using the form 1 : 0 to construct a solution.
>> I had not realised until then just how good
>> 1 : 0 is at composing tacit programs.
>>
>> The following example produces deltb, a tacit verb
>> that deletes leading and trailing blanks.
>>
>> deltb=: [: 1 : 0
>> a=.' ' ~: ] NB. non-blanks
>> b=. +./\ NB. true after first 1 (deletes leading )
>> c=. b &.|. NB. true until last 1 (delete trailing)
>> d=. b *. c NB. delete leading and trailing
>> e=. [: d a NB. put it together
>> (#~ e)f. NB. hook that modifies Copy
>> )
>> 5!:5<'deltb'
>> #~ ([: (+./\ *. +./\&.|.) ' ' ~: ])
>
> Isn't this more to do with f. Than 1 : 0 ?
>
> a=.' ' ~: ] NB. non-blanks
> b=. +./\ NB. true after first 1 (deletes leading )
> c=. b &.|. NB. true until last 1 (delete trailing)
> d=. b *. c NB. delete leading and trailing
> e=. [: d a NB. put it together
> deltb=: (#~ e) f. NB. hook that modifies Copy
> deltb
> #~ ([: (+./\ *. +./\&.|.) ' ' ~: ])
>
> Building a tacit verb this way in a script is a nice way of documenting what
> a tacit verb does without polluting the namespace with lots of component
> verbs once the script is loaded.
>
> I can see that the use of 1 : 0 would provide a similar effect if you were
> defining the verb directly in the session though - doesn't retain the
> documentation though.
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm