Certainly.
For example:
sum=: +/
div=: %
len=: #
mean=: sum div len
avg=: mean f.
fdot=: {{
m=. u`'' assert.3=4!:0<'u'
if. 1=L.m do.(5!:1 m)`:6 else.m`:6 end.
}}
mean f.`'' -: avg f.`''
1
mean fdot`'' -: avg fdot`''
0
FYI,
--
Raul
On Tue, May 3, 2022 at 11:56 PM Elijah Stone <[email protected]> wrote:
>
> There is a programming language-theoretic definition of equivalence (not
> restricted to functions). It is quite clever, but can be boiled down to: is
> there a way, within the language, to tell the difference between two values?
> Because j has no hard abstractions, the question of equality is rather simple,
> and is in fact pretty similar to u f.`'' -: v f.`''. Because--if you said u
> and v were equivalent, but -. u f.`'' -: v f.`'', then that is a way of
> distinguishing u and v, so they cannot be equivalent.
>
> That this allows you to distinguish {{x+y}} from {{x +y}} seems not very
> useful (though I can imagine cases where it would be important), but consider
> u versus u ((2 :'u y') :(2 :'x u y')) 0. This also seems useless, but I
> profited from a very similar distinction in the threading routines I posted
> here last month.
>
> I will add that, in a symbolic context, the name used to refer to something
> may have significance, which is another case in which preservation of
> input->output mapping is not exactly what you want to ensure; f. erases such
> information.
>
> f. also erases information about the target of $:, which may mean it considers
> to be identical verbs which actually behave differently.
>
> On Tue, 3 May 2022, Raul Miller wrote:
>
> > There isn't really a better way to do that test.
> >
> > Conceptually, what you want is a test that determines whether two
> > verbs would always produce the same results for the same arguments,
> > but that's a problem involving infinities. It's proof territory.
> >
> > That said, typically we solve this kind of problem by hand, rather
> > than using a test on the structure of the verb.
> >
> > Good luck,
> >
> > --
> > Raul
> >
> > On Tue, May 3, 2022 at 5:20 AM Ric Sherlock <[email protected]> wrote:
> >>
> >> I want to test if a particular verb was provided to my adverb.
> >> I came up with the solution below. Is there a better way?
> >>
> >> myadverb = {{
> >> res=. u {:y
> >> if. theverb f.`'' -: u f.`'' do.
> >> res=. ({.y) ,: res
> >> end.
> >> res
> >> }}
> >> ----------------------------------------------------------------------
> >> 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