Hello Dan;
The obvious case you mention is fine enough, yet...
dd =: monad : '5!:5<''y'''
dd 1 2 3 4 5 6 7
1 2 3 4 5 6 7
dd 1 2 3 4 5 6 7 8 NC. it takes its time to switch over.
1+i.8
dd ,:1 2 NB. The result exceeds ":
1+i.1 2
Which just means test as you go, the criterion is far from simple. Fair
enough.
Dan Bron wrote:
Randy wrote:
an actual test would confirm or refute this [whether the]
optimization results in a result smaller than what ": would give
I included such a test in the message you quoted:
5!:5{.;:'A'
29+14.5*i.1000000
":A
29 43.5 58 72.5 87 101.5 116 130.5 145 159.5 174 188.5 ...
Which confirms the optimized representation is smaller (and therefore quicker to communicate).
Try it yourself:
A =: 29+14.5*i.1e6 NB. Test data
B =: 5!:5<'A' NB. Optimized
C =: ": A NB. Unoptimized
#B NB. 17 charaters
17
#C NB. ~10 million characters
9688888
7!:5<'B' NB. 64 bytes
64
7!:5<'C' NB. ~30 million bytes
3.35544e7
10 (6!:2) '5!:5<''A''' NB. ~1/20 seconds to calculate
0.0424283
10 (6!:2) '":A' NB. ~2 seconds to calculate
1.7645
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
------------------------------------------------------------------------
|\/| Randy A MacDonald | APL: If you can say it, it's done.. (ram)
|/\| ramacd <at> nbnet.nb.ca |
|\ | | The only real problem with APL is that
BSc(Math) UNBF'83 | it is "still ahead of its time."
Sapere Aude | - Morten Kromberg
Natural Born APL'er |
-----------------------------------------------------(INTP)----{ gnat }-
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm