[Jprogramming] simple verb
Henry Rich
HenryHRich at nc.rr.com
Tue Jul 31 21:24:03 HKT 2007
Another solution is
(i.@# - i.~) 4 4 4 2 2 1 3 3 3 3
0 1 2 0 1 0 0 1 2 3
JfC shows Roger's solution for scrambled inputs.
Henry Rich
> -----Original Message-----
> From: programming-bounces at jsoftware.com
> [mailto:programming-bounces at jsoftware.com] On Behalf Of R.E. Boss
> Sent: Tuesday, July 31, 2007 8:59 AM
> To: 'Programming forum'
> Subject: RE: [Jprogramming] simple verb
>
> Alternative:
>
> (0:`+ @.[)/\.&.|. 0,2=/\4 4 4 2 2 1 3 3 3 3
> 0 1 2 0 1 0 0 1 2 3
>
> Works alsof or scrambled:
>
> (0:`+ @.[)/\.&.|. 0,2=/\3 1 4 3 3 4 3 2 4 2
> 0 0 0 0 1 0 0 0 0 0
>
>
> R.E. Boss
>
>
>
> > -----Oorspronkelijk bericht-----
> > Van: programming-bounces at jsoftware.com [mailto:programming-
> > bounces at jsoftware.com] Namens Mike Day
> > Verzonden: dinsdag 31 juli 2007 12:27
> > Aan: Programming forum
> > CC: damien.besombes at gmail.com
> > Onderwerp: Re: [Jprogramming] simple verb
> >
> > 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
> >
> > ;@((<@i.@#)/.~)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
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
More information about the Programming
mailing list