Roger wrote:
> To get exactly the same result as E.,
Now Roger, that's lying:
(,:'gr') E. 'the grass is ',:'always greener'
0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0
(,:'gr') myedot 'the grass is ',:'always greener' NB. For any
def, 'cept the last, which gives 0 0
|length error: myedot
| */"1 x ="1(#y){.(#x)[\y
(before anyone suggests it, myedot"_ 1 is not right either)
However, E. is readily modelled:
Edot =: [ -:"_ _1 (];.3~ $)~
(,:'gr') Edot 'the grass is ',:'always greener'
0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0
Or, if you prefer a \ solution, here's \ generalized to multiple dimensions:
cut_3 =: (] <@:|:\&>~ ({~ #@:$))^:(#@:[) < NB. <;._3
Edot =: $@:] {. <@:[ = (cut_3~ $)~ f.
(,:'gr') Edot 'the grass is ',:'always greener'
0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0
Arved: you might be interested in other primitive-equivalents:
http://www.jsoftware.com/jwiki/PrimitivePrimitives
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm