ListFindListReverse
Revision as of 14:18, 22 January 2015 by ObviousAltIsObvious Resident (talk | contribs) (<lsl> tag to <source>)
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials | User-Defined Functions | Void's User Page |
User-Defined Function: integer uListFindListReverse( list vLstSrc, list vLstTst );
Returns an integer index of the last instance of vLstTst in vLstSrc
- vLstSrc: source list to check
- vLstTst: list to look for
if vLstTst is not found in vLstSrc -1 is returned.
the index of the first element in vLstSrc is 0
Code:
- LSO: 168 Bytes
- MONO: 512 Bytes
integer uListFindListReverse( list vLstSrc, list vLstTst ){
integer vIntRtn;
if (vLstTst != []){
integer vIntPst = (vLstSrc != []);
while ((vIntRtn -= ~llListFindList( llList2List( vLstSrc, vIntRtn, vIntPst), vLstTst )) ^ vIntRtn );
}
return ~-vIntRtn;
}
/*//-- 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 ] //*/
/*//-- --//*/
Notes
- function loops n+1 times (where n = number of instances of vLstTst in vLstSrc).
- this may make it slow for large lists containing many copies of vLstTst
- Unlike llListFindList, this function properly returns -1 if either vLstSrc or vLstTst is an empty list([]).