Pascal wrote: "you may be aware that f@:g is only equivalent to [: f g if g
is fully parenthesize."


Yes, I am aware (see,
http://www.jsoftware.com/pipermail/general/2002-September/009912.html );
but, in my opinion, it is worth repeating often this subtle difference in
this forum.  Moreover, the adverb decap is also tacitly ;) "aware" as well:


   ([: +: +/) decap
+:@:(+/)
   ([: %: [: +/ [: *: ] - +/ % #) decap
%:@:(+/@:(*:@:(] - +/ % #)))

   tacit=. (13 :) ('decap'f.)

   '+&3 +: y' tacit
+&3@:+:

Decap can be written in extended J as follows (displaying the resolved
intermediate definitions for comprehensiveness; beware of wrapping):

   ( icf=. (((":verb) -: ('';0)f) *. ('[:' -: ('';1;0)f)) :: 0: )  NB.
Is an AR of a capped fork?
(((,'3') -: ('';0)&({::)) *. '[:' -: ('';1;0)&({::)) ::0:
   ( decapAR0=. (< o ('@:' j f. }. o (('';1)f))) t icf g )         NB.
Producing (u @: v) from ([: u v)
<@:('@:' ,&< }.@:(('';1)&({::)))^:icf"0
   ( decapAR=. $:e t (0 < L.) o decapAR0 )                         NB.
Inducting
$:&.>^:(0 < L.)@:decapAR0

   ( decap=. ([: train decapAR ('' $ '' tie ]) At)f.adv )  NB. Forcing
gerunds to ARs ('' $ '' tie ])
(1]:(<(,'0');(]:(<'`:'))&6@:($:&.>^:(0 < L.)@:(<@:('@:' ,&<
}.@:(('';1)&({::)))^:((((,'3') -: ('';0)&({::)) *. '[:' -: ('';1;0)&({::))
::0:)"0) (103!:0))@:('' $ '' (]:(<,'`')) ])))

Unfortunately, the last linear representation display cannot digest
properly the definition of decap; to be fair, this kind of food was never
on its menu.


On Tue, May 20, 2014 at 9:43 PM, 'Pascal Jasmin' via Programming <
[email protected]> wrote:

> regarding decap,
>
> you may be aware that f@:g is only equivalent to [: f g if g is fully
> parenthesized.
>
>    +:@:+/ 1 2 3
> 22
>    +:@:(+/) 1 2 3
> 12
>   ([: +: +/) 1 2 3
> 12
>
> At is super impressive to process and decompose a verb.
>
> I have a simpler process for macros described at
> http://www.jsoftware.com/jwiki/PascalJasmin/Multiline%20tacit%20expressions%20with%20macros
>
> I should have provided examples of macros outside of the multiline
> definition context:
>
> MACcompose =: 1 : 0 NB. inserts @: between consecutive verbs.  or adverb
> verb
> ;: inv ({. ;: m), 2 {:`('@:' , leaf {:)@.(((1=ncS@{. ) +. 3=ncS@{.) *.
> 3=ncS@{:)\ ;: m
> )
>
>
> eval =: 1 : ' a: 1 :  m'
> ncS=:3 :'z=.y 1 :y label_. 4!:0 <''z'' ' :: _2: NB. nameclass of string
>
>    '+ / + *'   MACcompose eval
> +/@:+@:*
>
> To be fancier, or correct, the MACcompose adverb should also check C N V
> (placing conjunction between N and V), and should preprocess parens to get
> a nameclass entity for what they contain.
>
> But there is a simple hack that has some convenience in escaping the
> composition, while still allowing any valid one:
>
> A =: 1 : 'u'
>
>    '+&3 +:'MACcompose_multiline_
> + & 3 +:  NB. no @: inserted because N V is parsed.
>
>    '+&3 A +:'MACcompose_multiline_
> + & 3 A @:+:  NB. inserting dummy adverb allows composition to trigger
>    '+&3 A +:'MACcompose_multiline_ eval
> +&3@:+:  NB. A is automatically stripped out in tacit conversion
>
> There is an even simpler definition of MACcompose, that requires no hack
> for correct composition
>
>    '+&3 +: y' (13 :)
> [: +&3 +:
>
>
> This type of macro or whole line processing can be a big enhancement to J
> in that it allows inserting any conjunction between verb phrases.  While @:
> is the most common and convenient, short circuits or code that signals and
> captures escapes (errors) to abort further processing are useful generic
> processes best defined as a conjunction.
>
>
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to