Dear xperts J-ers,
Here are two versions for aiken code generation
based on the same algorithm.
+-------+-------+
|bin |aiken |
+-------+-------+
|0 0 0 0|0 0 0 0|
|0 0 0 1|0 0 0 1|
|0 0 1 0|0 0 1 0|
|0 0 1 1|0 0 1 1|
|0 1 0 0|0 1 0 0|
|0 1 0 1|1 0 1 1|
|0 1 1 0|1 1 0 0|
|0 1 1 1|1 1 0 1|
|1 0 0 0|1 1 1 0|
|1 0 0 1|1 1 1 1|
+-------+-------+
I.
aikenDX1=:3 :'(,(<:3*2^y-2)+])i.1+2^y-2'
---------
A
II.
aikenD=:([:i.1+2^2-~]),([:<:3*2^2-~])+[:i.1+2^2-~]
------------- ------------
A B
(aikenDX1 -: aikenD) 21
1
Observation shows that verb I is a bit faster.
Q1: Is it possible to make version I tacit not
in the way of verb II?
(I expect not: y has to be known on two levels
of tacit as I may put it that way, but ...?)
Q2: In verb II parts A and B are the same.
Will A be a copy of B (optimization)
or is it calculated/generated again?
Q3: other approaches for a solution
TIA,
@@i
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm