[Jprogramming] J weirdness #2 - A nasty surprise
Raul Miller
rauldmiller at gmail.com
Mon Apr 17 21:03:34 UTC 2017
I think you were surprised by
http://www.jsoftware.com/help/dictionary/special.htm
Specifically the special handling for +/ .* (which is handled at
parsing time rather than at execution time - the way you have things
arranged, the parser will not see +/ .* and hypothetically you could
arrange for sum .* in contexts where sum was defined differently).
I hope this helps,
--
Raul
On Mon, Apr 17, 2017 at 4:51 PM, Michael Goodrich
<michael.goodrich at gmail.com> wrote:
> Greetings:
>
> Got a nasty surprise today. have a non-trivial J app with the following
> supporting original definitions:
>
> sum =. +/
> dot =. +/ . *
> sqrd =. *:
> ssq =. +/ @: sqrd
>
>
> Which I changed (thinking I was being elegant) to
>
> sum =. +/
> dot =. sum . *
> sqrd =. *:
> ssq =. sum @: sqrd
>
> After this change the run time increased by a factor of 5!
>
> Insights?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list