Tally works whether or not the first element is 0 or 1 and,while I used
index 1 as default in APL, I will stick with index 0 in J as it saves a
lot of hassle.
Don
On 30/08/2014 5:21 PM, robert therriault wrote:
Whoops,
Don, for some reason I got it into my head that you wanted to keep the first
zero. Nub would work against you in that case as it would hold on to the first
zero and remove the rest.
You could always just remove the 0 using Less (-.) in this case the Passive
version (-.~)
0-.~ ( i.#arr) * +./"1 'cd' E."1 arr
1 3 5 7 9
Cheers, bob
On Aug 30, 2014, at 4:50 PM, robert therriault <[email protected]> wrote:
Hi Don,
I think that copy (#) combined with increment (>:) may be able to do the trick.
1 1 0 0 1#i.5 NB.index 0
0 1 4
1 1 0 0 1>:@#i.5 NB.index 1
1 2 5
Although reading through your journey to get to this point I wonder if Nub (~.)
would do the trick.
arr
ab
cd
yyy
jcd
ab
cd
yyy
jcd
ab
cd
+./"1 'cd' E."1 arr
0 1 0 1 0 1 0 1 0 1
( i.#arr) * +./"1 'cd' E."1 arr
0 1 0 3 0 5 0 7 0 9
~. ( i.#arr) * +./"1 'cd' E."1 arr
0 1 3 5 7 9
Cheers, bob
On Aug 30, 2014, at 4:30 PM, Don Kelly <[email protected]> wrote:
1 1 0 0 1/⍳5
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm