Damien

This works, but only if the data is in the form
[x =: 3 2 1 4 # 4 2 1 3 4 4 4 2 2 1 3 3 3 3
  NB. and not scrambled, eg
  y =: 3 1 4 3 3 4 3 2 4 2

  ;@((<@[EMAIL PROTECTED])/.~)x  NB. developed from your solution
0 1 2 0 1 0 0 1 2 3

Is that what you need or do you also need a
result for scrambled x?

Mike

Damien wrote:
Hi,

I have a problem to create a verb. I think it is quite easy, but
unfortunately I can not.

My Input (example) :     4 4 4 2 2 1 3 3 3 3
As output, I would :       0 1 2 0 1 0 0 1 2 3

I would like a verb which counts the iteration number for same element.
It is equivalent to : (i. 3) , ( i. 2) , ( i. 1) , ( i. 4)
I can do the line above because of the parenthesis.
I can only get the vector : 3 2 1 4 easily with #/.~, but that is all.
Any idea ?

Thank you. Bye.
Damien.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to