Array function lastIndexOf

Jul 12, 2006 at 4:53am

Array function lastIndexOf

#26766
Jul 12, 2006 at 7:22am

Paul,

On 12 juil. 06, at 06:53, Paul Hertz wrote:

> I have been attempting to use the array function lastIndexOf, which is
> documented as a standard function belonging to the Array class:
>
> http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:
> Global_Objects:Array:lastIndexOf

I read on this webpage that lastIndexOf has been implemented in
JavaScript 1.6 (although the doc is for 1.5!) but Max runs a JavaScript
1.5 version.
There is no mention of this method for the Array class in my 1.5
documentation (the method exists only for String). I’m afraid you’ll
have to implement it yourself!

_____________________________
Patrick Delges

Centre de Recherches et de Formation Musicales de Wallonie asbl

http://users.skynet.be/crfmw/max

#80443
Jul 12, 2006 at 7:41am

>> I have been attempting to use the array function lastIndexOf,
>> which is
>> documented as a standard function belonging to the Array class:
>>
>> http://developer.mozilla.org/en/docs/
>> Core_JavaScript_1.5_Reference:Global_Objects:Array:lastIndexOf
>
> I read on this webpage that lastIndexOf has been implemented in
> JavaScript 1.6 (although the doc is for 1.5!) but Max runs a
> JavaScript 1.5 version.
> There is no mention of this method for the Array class in my 1.5
> documentation (the method exists only for String). I’m afraid
> you’ll have to implement it yourself!

try:

outlet(0, s1.toString().lastIndexOf(“goo”));

a little clunky, but should do it.
vb

#80444
Jul 12, 2006 at 1:28pm

Thanks, Patrick,

I concluded the same almost as soon as I sent the message–a closer
look at the documentation revealed that indexOf and lastIndexOf are
1.6 features.

Sending a message to a list has a way of making solutions suddenly
leap out at you. It must be a psycho-logical phenomenon akin to flow.

– Paul

On 7/12/06, Patrick Delges

wrote:
> Paul,
>
> On 12 juil. 06, at 06:53, Paul Hertz wrote:
>
> > I have been attempting to use the array function lastIndexOf, which is
> > documented as a standard function belonging to the Array class:
> >
> > http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:
> > Global_Objects:Array:lastIndexOf
>
> I read on this webpage that lastIndexOf has been implemented in
> JavaScript 1.6 (although the doc is for 1.5!) but Max runs a JavaScript
> 1.5 version.
> There is no mention of this method for the Array class in my 1.5
> documentation (the method exists only for String). I’m afraid you’ll
> have to implement it yourself!
>
> _____________________________
> Patrick Delges
>
> Centre de Recherches et de Formation Musicales de Wallonie asbl
> http://users.skynet.be/crfmw/max
>
>


—– |(*,+,#,=)(#,=,*,+)(=,#,+,*)(+,*,=,#)| —–

#80445
Jul 12, 2006 at 1:37pm

Well, that gets me the index of a char in a string, not the array
index. As Patrick says, I’d have to roll my own to get the array
index, which AFAIK implies stepping through the array. If I reeeally
want to insist, I can add the function to the Array prototype, which I
think would make it global within a single session’s shared JS global
“world.”

The richer vocabulary of Java is a great comfort in these situations.

– Paul

On 7/12/06, vb wrote:
> >> I have been attempting to use the array function lastIndexOf,
> >> which is
> >> documented as a standard function belonging to the Array class:
> >>
> >> http://developer.mozilla.org/en/docs/
> >> Core_JavaScript_1.5_Reference:Global_Objects:Array:lastIndexOf
> >
> > I read on this webpage that lastIndexOf has been implemented in
> > JavaScript 1.6 (although the doc is for 1.5!) but Max runs a
> > JavaScript 1.5 version.
> > There is no mention of this method for the Array class in my 1.5
> > documentation (the method exists only for String). I’m afraid
> > you’ll have to implement it yourself!
>
> try:
>
> outlet(0, s1.toString().lastIndexOf(“goo”));
>
> a little clunky, but should do it.
> vb
>
>
>
>


—– |(*,+,#,=)(#,=,*,+)(=,#,+,*)(+,*,=,#)| —–

#80446
Jul 13, 2006 at 9:57am

On 12 Jul 2006, at 15:37, Paul Hertz wrote:

> Well, that gets me the index of a char in a string, not the array
> index.

ok, now i understand what you actually want.
sorry for the confusion.
vb.

#80447

You must be logged in to reply to this topic.