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