Difference between revisions of "User talk:Void Singer/Functions"
Void Singer (talk | contribs) m (→What does uListFindAnyLast function do?: thanks for the bug report) |
Void Singer (talk | contribs) m (updated from LSL tags to SOURCE tags) |
||
Line 15: | Line 15: | ||
using the following script: | using the following script: | ||
< | <source lang="lsl2"> | ||
integer uListFindAnyLast( list vLstSrc, list vLstTst ){ | integer uListFindAnyLast( list vLstSrc, list vLstTst ){ | ||
return (vLstSrc != []) - | return (vLstSrc != []) - | ||
Line 40: | Line 40: | ||
} | } | ||
} | } | ||
</ | </source> | ||
The output is: | The output is: |
Latest revision as of 07:27, 26 January 2015
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:
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"));
}
}
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)