Difference between revisions of "User talk:Void Singer/Functions"

From Second Life Wiki
Jump to navigation Jump to search
(What does uListFindAnyLast function do?)
 
Line 48: Line 48:


How can that be 1? Either way round you turn the list, the element "a" is at index 0 and 2... How come you get 1?
How can that be 1? Either way round you turn the list, the element "a" is at index 0 and 2... How come you get 1?
: I do believe you have found an unspotted edge case (element that is being looked for appears at the end of the list). I think it might require a less elegant solution to squash it. -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 11:34, 25 May 2012 (PDT)

Revision as of 11:34, 25 May 2012

What does uListFindAnyLast function do?

What's the purpose of this function? It does not seem to work correctly for base cases. Then again, since there's no provided documentation, I'm not really sure if I'm using it properly.

I am searching for element:

a

in the list:

a b a

using the following script:

<lsl> integer uListFindAnyLast( list vLstSrc, list vLstTst ){

 return (vLstSrc != []) -
   (llParseString2List(
      llList2String(
        llParseString2List( 
          llDumpList2String( vLstSrc, "•" ),
          vLstTst, [] ),
        -1 ),
      (list)"•",
      [] ) != []) - 1;

}

/*//-- Anti-License Text --//*/ /*// Contributed Freely to the Public Domain without limitation. //*/ /*// 2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ] //*/ /*// Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ] //*/ /*//-- --//*/

default {

   state_entry() {
       list l_1 = [ "a", "b", "a"];
       llOwnerSay((string)uListFindAnyLast(l_1, (list)"a"));
   }

} </lsl>

The output is:

Object: 1

How can that be 1? Either way round you turn the list, the element "a" is at index 0 and 2... How come you get 1?

I do believe you have found an unspotted edge case (element that is being looked for appears at the end of the list). I think it might require a less elegant solution to squash it. -- Strife (talk|contribs) 11:34, 25 May 2012 (PDT)