Though we may roll our own uses, the most common use of gerunds are the embedded series of verbs passed to @. and `:
For @. anyway setting the rank of a gerund element to "_ is pretty safe because it will never exceed the rank of @.v, and almost always, you want these ranks to be equal anyway. I found a one line solution that also doesn't mangle ranks of verbs that are already verbs. It turns out I was struggling with :: only working with verbs. vtie =: 2 : 'try. ((u"_)`(v"_)"_)^:(0=L.) (u`v) catch. try. u`(v"_) catch. (u"_)`(v"_) end. end.' - vtie + ┌─┬─┐ │-│+│ └─┴─┘ + vtie 3 ┌─┬─────────────────┐ │+│┌─┬─────────────┐│ │ ││"│┌─────┬─────┐││ │ ││ ││┌─┬─┐│┌─┬─┐│││ │ ││ │││0│3│││0│_││││ │ ││ ││└─┴─┘│└─┴─┘│││ │ ││ │└─────┴─────┘││ │ │└─┴─────────────┘│ └─┴─────────────────┘ 2 vtie + ┌─────────────────┬─────────────┐ │┌─┬─────────────┐│┌─┬─────────┐│ ││"│┌─────┬─────┐│││"│┌─┬─────┐││ ││ ││┌─┬─┐│┌─┬─┐││││ ││+│┌─┬─┐│││ ││ │││0│2│││0│_│││││ ││ ││0│_││││ ││ ││└─┴─┘│└─┴─┘││││ ││ │└─┴─┘│││ ││ │└─────┴─────┘│││ │└─┴─────┘││ │└─┴─────────────┘│└─┴─────────┘│ └─────────────────┴─────────────┘ 2 vtie 3 ┌─────────────────┬─────────────────┐ │┌─┬─────────────┐│┌─┬─────────────┐│ ││"│┌─────┬─────┐│││"│┌─────┬─────┐││ ││ ││┌─┬─┐│┌─┬─┐││││ ││┌─┬─┐│┌─┬─┐│││ ││ │││0│2│││0│_│││││ │││0│3│││0│_││││ ││ ││└─┴─┘│└─┴─┘││││ ││└─┴─┘│└─┴─┘│││ ││ │└─────┴─────┘│││ │└─────┴─────┘││ │└─┴─────────────┘│└─┴─────────────┘│ └─────────────────┴─────────────────┘ 33 vtie 22 vtie -: @. * i:3 _1.5 _1 _0.5 33 22 22 22 ----- Original Message ----- From: Raul Miller <[email protected]> To: Programming forum <[email protected]> Cc: Sent: Wednesday, February 5, 2014 10:56:41 AM Subject: Re: [Jprogramming] Re {programming] setting rank to a a conjunction I think I see where you are going with this. Basically I think you are trying to conceive of an alternative for ` which is closer in character to ; (In other words: the leftmost verb in a gerund train can have an explicit "_ without needing extra parenthesis but that's not the case for remaining verbs, and a related issue is that gerunds are meant to nounify verbs, so automatically promoting nouns to the mix might be a good thing.) But I think I'd use the word 'then' rather than 'else4' to label the concept, but the concept itself seems valid. (Also, of course, there are some cases where it's important to preserve the original rank of a verb. But that's a different context.) Thanks, -- Raul On Wed, Feb 5, 2014 at 10:31 AM, Pascal Jasmin <[email protected]> wrote: > The purpose is syntax sugar for mixing and matching verb and nouns into a > gerund > > (+:"_) `(3"_)` (-:"_) > > this works/equivalent and has less line noise. (dont have to specify rank to > noun when it is right argument to conjunction). It can be used with either > my version of if, or just @. > > +: else4 3 else4 -: > > > 3: else4 0 else4 -: @. * i:3 > _1.5 _1 _0.5 3 0 0 0 > > > > > ----- Original Message ----- > From: Raul Miller <[email protected]> > To: Programming forum <[email protected]> > Cc: > Sent: Wednesday, February 5, 2014 9:52:43 AM > Subject: Re: [Jprogramming] Re {programming] setting rank to a a conjunction > > Why are you using 'else' without 'if'? > > As near as I can tell, you are trying to construct a gerund, why use > 'else' at all in this case? > > Thanks, > > -- > Raul > > > On Wed, Feb 5, 2014 at 9:51 AM, Pascal Jasmin <[email protected]> wrote: >> 3"_`(+:"_)` (-:"_) >> ┌─────────────────┬──────────────┬──────────────┐ >> │┌─┬─────────────┐│┌─┬──────────┐│┌─┬──────────┐│ >> ││"│┌─────┬─────┐│││"│┌──┬─────┐│││"│┌──┬─────┐││ >> ││ ││┌─┬─┐│┌─┬─┐││││ ││+:│┌─┬─┐││││ ││-:│┌─┬─┐│││ >> ││ │││0│3│││0│_│││││ ││ ││0│_│││││ ││ ││0│_││││ >> ││ ││└─┴─┘│└─┴─┘││││ ││ │└─┴─┘││││ ││ │└─┴─┘│││ >> ││ │└─────┴─────┘│││ │└──┴─────┘│││ │└──┴─────┘││ >> │└─┴─────────────┘│└─┴──────────┘│└─┴──────────┘│ >> └─────────────────┴──────────────┴──────────────┘ >> >> instead I got result from: >> >> 3"_`+:"_` (-:"_) >> >> a workaround is: >> >> else4 =: 2 : ('u`(v"_)') >> >> >> 3"_ else4 +: else4 (-:) NB. provides same correct output as top. >> >> >> but you have to remember to verbify the leftmost argument. >> >> >> >> ----- Original Message ----- >> From: Raul Miller <[email protected]> >> To: Programming forum <[email protected]> >> Cc: >> Sent: Wednesday, February 5, 2014 9:21:15 AM >> Subject: Re: [Jprogramming] Re {programming] setting rank to a a conjunction >> >> Can you explain what result you want to achieve here? >> >> Thanks, >> >> -- >> Raul >> >> >> On Wed, Feb 5, 2014 at 9:09 AM, Pascal Jasmin <[email protected]> wrote: >>> And conjunctions are deprived of that opportunity. >>> >>> An example from the other thread, the conjunction: >>> >>> else =: 2 : '(u"_)`(v"_)' >>> >>> >>> seems like a useful replacement to tie if you want eye candy for >>> "verbifying" any of its arguments, but it doesn't actually work for >>> multiple applications: >>> >>> 3"_`+:`-: >>> ┌─────────────────┬──┬──┐ >>> │┌─┬─────────────┐│+:│-:│ >>> ││"│┌─────┬─────┐││ │ │ >>> ││ ││┌─┬─┐│┌─┬─┐│││ │ │ >>> ││ │││0│3│││0│_││││ │ │ >>> ││ ││└─┴─┘│└─┴─┘│││ │ │ >>> ││ │└─────┴─────┘││ │ │ >>> │└─┴─────────────┘│ │ │ >>> └─────────────────┴──┴──┘ >>> >>> produces 3 elements, but: >>> >>> 3"_`+:else -: >>> ┌──────────────────────────────────────┬──────────────┐ >>> │┌─┬──────────────────────────────────┐│┌─┬──────────┐│ >>> ││"│┌──────────────────────────┬─────┐│││"│┌──┬─────┐││ >>> ││ ││┌─┬──────────────────────┐│┌─┬─┐││││ ││-:│┌─┬─┐│││ >>> ││ │││0│┌─────────────────┬──┐│││0│_│││││ ││ ││0│_││││ >>> ││ │││ ││┌─┬─────────────┐│+:│││└─┴─┘││││ ││ │└─┴─┘│││ >>> ││ │││ │││"│┌─────┬─────┐││ │││ ││││ │└──┴─────┘││ >>> ││ │││ │││ ││┌─┬─┐│┌─┬─┐│││ │││ │││└─┴──────────┘│ >>> ││ │││ │││ │││0│3│││0│_││││ │││ │││ │ >>> ││ │││ │││ ││└─┴─┘│└─┴─┘│││ │││ │││ │ >>> ││ │││ │││ │└─────┴─────┘││ │││ │││ │ >>> ││ │││ ││└─┴─────────────┘│ │││ │││ │ >>> ││ │││ │└─────────────────┴──┘││ │││ │ >>> ││ ││└─┴──────────────────────┘│ │││ │ >>> ││ │└──────────────────────────┴─────┘││ │ >>> │└─┴──────────────────────────────────┘│ │ >>> └──────────────────────────────────────┴──────────────┘ >>> >>> produces only 2, as it applies rank to its entire u argument. >>> >>> >>> >>> ----- Original Message ----- >>> From: Raul Miller <[email protected]> >>> To: Programming forum <[email protected]> >>> Cc: >>> Sent: Tuesday, February 4, 2014 9:00:42 PM >>> Subject: Re: [Jprogramming] Re {programming] setting rank to a a conjunction >>> >>> While you cannot "apply" rank to an adverb you can arrange for it to >>> be applied to the result of the adverb. >>> >>> For example >>> Red=: /("1) >>> +Red i.3 3 >>> 3 12 21 >>> >>> Thanks, >>> >>> -- >>> Raul >>> >>> >>> On Tue, Feb 4, 2014 at 8:08 PM, Don Guinn <[email protected]> wrote: >>>> OK. You're right it can be applied to nouns. But then it makes a constant >>>> verb. What it cannot be applied to is an adverb or conjunction. Not that >>>> there haven't been times that I wish that it could. >>>> >>>> >>>> On Tue, Feb 4, 2014 at 5:26 PM, Dan Bron <[email protected]> wrote: >>>> >>>>> Hey now, don't rile the pedant. Rank also accepts noun LHA (and, FWIW, >>>>> verb RHAs). >>>>> >>>>> That said, by definition, 13 : n will produce a verb, no matter what n >>>>> is. (Well, ok, either a verb or an error.) >>>>> >>>>> -Dan >>>>> >>>>> >>>>> > On Feb 4, 2014, at 8:17 AM, Don Guinn <[email protected]> wrote: >>>>> > >>>>> > The rank conjunction only applies to verbs. >>>>> > >>>>> > >>>>> >> On Tue, Feb 4, 2014 at 3:05 AM, linda <[email protected]> wrote: >>>>> >> >>>>> >> In an earlier post : >>>>> >> >>>>> >> >>>>> >> >>>>> >> t2=: 13 : '*/ |: y ' >>>>> >> >>>>> >> t2 >>>>> >> >>>>> >> [: + / |: >>>>> >> >>>>> >> >>>>> >> >>>>> >> Also: J "does it your way" >>>>> >> >>>>> >> >>>>> >> >>>>> >> t3 =: 13 : ']@:+/"1 y ' >>>>> >> >>>>> >> t3 >>>>> >> >>>>> >> ]@:+/"1 >>>>> >> >>>>> >> >>>>> >> >>>>> >> t3 3 3 $ i.9 >>>>> >> >>>>> >> 3 12 2` >>>>> >> >>>>> >> >>>>> >> >>>>> >> >>>>> >> >>>>> >> t3 is a verb, instead of a conjunction. >>>>> >> >>>>> >> >>>>> >> >>>>> >> Linda >>>>> >> >>>>> >> >>>>> >> >>>>> >> ---------------------------------------------------------------------- >>>>> >> For information about J forums see 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 >>>>> >>>> ---------------------------------------------------------------------- >>>> For information about J forums see 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 >> ---------------------------------------------------------------------- >> For information about J forums see 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 > ---------------------------------------------------------------------- > For information about J forums see 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
