And... because it was bothering me, here's a version of the fork
adverb which works around the problem with 5!:6 which was bothering
me:
fork=: {{)a
if. (10{a.) e. 5!:6 <'u' do.
0!:0'u=. {{u ((',(5!:6<'u'[u=.5!:1<'u'),')5!:0) v}}'
else.
0!:0'u=. {{u (',(5!:6<'u'),') v}}'
end.
u
}}
And here's how it looks in action:
div=: {{
NB. division
x % y
}}
+/ div f. fork # 1 2 3
2
It's not pretty, but it works...
And I hope it's clear why I wanted this to be in a different message
from my previous suggestion of a fork primitive: This kind of
complexity can be distracting.
Thanks,
--
Raul
On Tue, Sep 28, 2021 at 11:49 AM Raul Miller <[email protected]> wrote:
>
> Er... actually, I should have gone with
>
> fork=: {{)a
> 0!:0'u=. {{u (',(5!:6<'u'),') v}}'
> u
> }}
>
> This still has a problem in some cases, but this fixes some other
> problems which I had not been thinking about.
>
> Thanks,
>
> --
> Raul
>
> On Tue, Sep 28, 2021 at 11:46 AM Raul Miller <[email protected]> wrote:
> >
> > However, a "hook adverb" is relatively easy to create tacitly:
> >
> > hook=: ]:
> >
> > Ok, ok... that's actually a joke, since the hook formation happens
> > outside of the adverb (and, thus, is vulnerable to adjacent nouns in
> > the sentence).
> >
> > Still... it's relatively straightforward to create an explicit fork adverb:
> >
> > fork=: {{)a
> > ".'u=. {{u ',(5!:6<'u'),' v}}'
> > u
> > }}
> >
> > +/ % fork # 1 2 3
> > 2
> >
> > (Granted, this will have problems in some cases because of a
> > limitation of the current 5!:6 implementation. We could detect those
> > cases and work around the problem, but doing that would contribute
> > nothing useful here.)
> >
> > But, ... anyways, having actual language primitives for hook and fork
> > might be useful for the tacit construction crowd.
> >
> > It's just kind of ironic that the simplest hook primitive would be a
> > conjunction while the simplest fork primitive would be an adverb.
> >
> > Thanks,
> >
> > --
> > Raul
> >
> > On Tue, Sep 28, 2021 at 6:14 AM Elijah Stone <[email protected]> wrote:
> > >
> > > On Mon, 27 Sep 2021, Henry Rich wrote:
> > >
> > > > All I would be interested in reading is a SHORT example of something
> > > > that can't be done without changing the language.
> > >
> > > Currently possible, but very inconvenient: define a 'hook' conjunction
> > > tacitly. (Useless as such, but useful if one wishes to produce a hook
> > > from a tacit modifier, as I did.) I was able to come up with the
> > > following abomination: ']. (([:(]: ]: ])) (]:~) [) [.'. Compare with the
> > > explicit {{u v}}. (It simplifies if one cares only about the monadic
> > > case, which was the case for me, but not by much.)
> > >
> > > I propose a conjunctive fork: interpret C0 C1 (which is currently
> > > meaningless) as (u C0 v) (u C1 v).
> > >
> > > This doesn't solve the more general problem of producing arbitrary
> > > forks-- _some_ arrangement of C0 C1 C2 should give u C0 v u C1 v u C2 v
> > > --but would still be helpful.
> > >
> > > -E
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm