User talk:Void Singer/Functions

From Second Life Wiki
< User talk:Void Singer
Revision as of 09:15, 23 May 2012 by Kira Komarov (talk | contribs) (What does uListFindAnyLast function do?)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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?