Pascal wrote:
"
I doubt it does,

timespacex '123 ([: <. %~) 210293810238120398120398120398x + i.1000'
0.00241248 1.27885e6
timespacex '123 ( <.@%~) 210293810238120398120398120398x + i.1000'
0.000590399 836992
"

In other words, another  [: u v  beats the dust vs  u @: v ;) and just to
leave no doubt about it:

   Cut=. -.&a: @: (<;._2@,~)
   st=. (, */&.:>@:(1 2&{))@:(] ; 7!:2@:] ; 6!:2)
   stp2=. [ ((;:'Sentence Space Time Product') , st&>) LF Cut ]

   stp=. 1&stp2 : stp2 f.

   X=. 123 [ Y=. 210293810238120398120398120398x + i.1000


   assert X (2 -:/\ ([: <. %~) ; (<.@%~) ; (<.@:%~)) Y

   11 stp noun define
X ([: <.  %~) Y
X (   <.@ %~) Y
X (   <.@:%~) Y
)
┌───────────────┬──────┬──────────────┬──────────┐
│Sentence       │Space │Time          │Product   │
├───────────────┼──────┼──────────────┼──────────┤
│X ([: <.  %~) Y│852992│0.00256262107 │2185.89527│
├───────────────┼──────┼──────────────┼──────────┤
│X (   <.@ %~) Y│411136│0.000426300912│175.267652│
├───────────────┼──────┼──────────────┼──────────┤
│X (   <.@:%~) Y│411136│0.000428377639│176.121469│
└───────────────┴──────┴──────────────┴──────────┘

Linda wrote:
"
Interesting...  I always wondered if "special code" always works or justs
sometimes in specific situations?  If the special code always works when
encountered, then [:/:/: sould be equivalent to /:@/:  as they are
otherewise equivalent.
"

As Dan pointed out, theoretical equivalence does not (necessarily) imply
practical equivalence.  First there was @:, [: came afterwards and it seems
[: has been playing catch up ever since which means at least for a decade;
 see, for example, [1, 2, and 3] (I tried to become a [: fan in vain [2]).
The current version of the tacit converter (13 :) favors [: over @: and its
fans, and also [: fans, should be aware of potential performance drawbacks.

[0] [Jforum] @:-train implementation
    http://www.jsoftware.com/pipermail/general/2003-August/014524.html

[1] [Jforum] @:-train implementation
    http://www.jsoftware.com/pipermail/general/2003-August/014525.html

[2] [Jprogramming] rosettacode
    http://www.jsoftware.com/pipermail/programming/2013-May/032602.html


On Wed, Jan 20, 2016 at 10:02 AM, Dan Bron <[email protected]> wrote:

> Linda wrote:
> > Interesting...  I always wondered if "special code" always works or
> justs sometimes in specific situations?  If the special code always works
> when encountered, then [:/:/: sould be equivalent to /:@/:  as they are
> otherewise equivalent.
>
> Well, x * y and x +&^. y are “otherwise” equivalent, but one uses the
> multiplier and one uses the ALU, so they are not equivalent in performance.
>
> Or do you expect J to recognize their mathematical equivalence?  A
> desirable goal, to be sure, but somewhat unrealistic.
>
> Special code is just that: special. It recognizes certain special cases,
> and optimizes (only) those cases. If all possible cases were optimized, it
> would fall under “implementation”  as opposed to “special code”.
>
> For example, there is a *lot* of optimization in i., but only some of it
> falls under the rubric of “special code”.
>
> Anyway, if you want to take advantage of special code, you must use the
> forms J has optimized, even if they’re not your preferred forms (for
> example, I much prefer (N V~ V) to (V V N”_) but where (E. i. 1:) is
> optimized, (1 i.~ E.) isn’t).
>
> The optimized forms are listed, explicitly and comprehensively, in the DOJ
> under Appendix B [1].
>
> -Dan
>
> [1] Dictionary of J, Appendix B, “Special Code”:
>     http://www.jsoftware.com/help/dictionary/special.htm <
> http://www.jsoftware.com/help/dictionary/special.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

Reply via email to