If you want to create a verb that produces (x u v y) if
dyadic or (u v y) if monadic, you can use
[EMAIL PROTECTED] : (u v)
but this has a problem: the values of u and v are repeated.
If you have several conjunctions in this form, passing verb
results down the line, the resulting final verb can be
enormous. (This actually happened to me in an application).
Another way to achieve the same result is the trick
u^:(1:`(]v))
which you can understand by looking at the fine print of ^: .
This version does not repeat u and v and so grows only linearly
as the verbs get complicated.
This idea can be used in the current problem:
R4 =: 1 : 'u~/@|.@(u^:(1:`(]{.)) [`0:`]} ])'
I haven't tested this but it looks right.
Henry Rich
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Raul Miller
> Sent: Saturday, November 24, 2007 7:46 AM
> To: General forum
> Subject: Re: re[Jgeneral] duce/fold in J as an adverb or conjuction
>
> Dan Bron's posts have triggered my sluggish thinking into realizing
> how to make a tacit instance of R:
>
> R3=:1 :0
> u~/@|.@([EMAIL PROTECTED]@]`0:`]}~) :( u~/@|.@((u {.)`0:`]}))
> )
>
> Or, if you prefer
>
> R4=:1 :(0 :0-.LF)
> u~/@|.@([EMAIL PROTECTED]@]`0:`]}~)
> :
> (u~/@|.@((u {.)`0:`]}))
> )
>
> If you type that in manually, note that the : in R4 should
> be indented.
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see
> http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm