ts '1 1 1 +./@E. (1 1 1 ,100000$0)' 8.1599503875016434e_5 263936 ts '+./3*./\ (1 1 1 ,100000$0)' 0.00061567625668835938 395072 ts '+./ 1 1 1 E. (1 1 1 ,100000$0)' 0.0003145580874868281 394880
So the phrase +./@E. must have an early out for a single matched pattern. But 3*./\ compares poorly to +./ 111 E. even without the early That is an enormous difference. I found the special code page, thanks to the above, I guess I need to study it if I want to write excellent code. For one thing, had I read through that page, there is one of the euler problems that would have been trivial and short, it was something like computing the last few digits of a large number to a large power. There is a special case in there x (n|@^)y that would have made the solution to the problem instant and trivial, without the @ it takes more than an hour - and that is how I did it, sigh. One thing that bothers me is the first thing in the list: In the old days of APL, one could reshape a structure directly (as an in line result, of course, not as a side effect) with rho. I had noticed that that didn't quite work here. 3 3 $ i. 2 3 4 is not the same as 3 3 $, i. 2 3 4. Once I learned that it didn't bother me. I had sort of presumed that the difference between a vector and a matrix as an intermediate result might have been nothing more than a flag saying, "this is a vector of L20' without any actual rearranging. (I tried this in NARS2000, and it did not work as I expected it to, but the malfunction is basic, I could not reduce the output of (3 3 rho iota 2 3 4)=(3 3 rho , iota 2 3 4) to a single number no matter how many ravels and compresses I stacked up, it kept displaying 1 1 1. NARS2000 is very ambitious, and is admitted to not be prime time. But the two sides of the expression agreed in shape and numeric value. So I was wrong about J, and there is some rearranging, to the point where ($,) skips the rearranging while $, does not, and this saves some work. ($,) is faster than $, but why would you not always use the "better" code? Why not use the better code any time you see $,? Now I understand that most of these things are only special when they are glued with @ or &. Why is this one special as a hook without glue? Is it because $@, does not have the same semantics as $,? Is this the only phrase that needs to be expressed as a hook to crank up the special code? I'm taken aback by the number of cases that have special case code - some of the code is functional, like the code that doesn't calculate unused parts of the result, and some just seems to be code that was put in to speed things up. I don't think I can memorize everything I will need. -- Of course I can ride in the carpool lane, officer. Jesus is my constant companion. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
