User talk:Void Singer/Functions

From Second Life Wiki
< User talk:Void Singer
Revision as of 08:27, 26 January 2015 by Void Singer (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, 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:


in the list:

a b a

using the following script:

integer uListFindAnyLast( list vLstSrc, list vLstTst ){
  return (vLstSrc != []) -
           llDumpList2String( vLstSrc, "•" ),
           vLstTst, [] ),
         -1 ),
       [] ) != []) - 1;
/*//--                       Anti-License Text                         --//*/
/*//     Contributed Freely to the Public Domain without limitation.     //*/
/*//   2009 (CC0) [ ]   //*/
/*//  Void Singer [ ]  //*/
/*//--                                                                 --//*/
default {
    state_entry() {
        list l_1 = [ "a", "b", "a"];
        llOwnerSay((string)uListFindAnyLast(l_1, (list)"a"));

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? [previous unsigned comment by Kira Komarov 10:15, 23 May 2012]

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)

The original function is misprinted here, and should have used llParseStringKeepNulls in place of the inner llParseString2List (I must have copied an older version from when I was working it up), thanks for pointing out that it was broken. I originally de-linked it from the llListFindList article because the correct version didn't handle null strings (so too limited) and I intended to try and rework it to support that case. As to it's purpose, it's clearly stated on the page that it's intention to "Get the Last index in List Source of Any element in List Test". the broken version is now replaced with a more optimized (working) version, as are it's cousin functions.
-- Void (talk|contribs) 19:59, 3 June 2012 (PDT)