ListReverse
Jump to navigation
Jump to search
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials | User-Defined Functions | Void's User Page |
User-Defined Function: list uListReverse( list vLstSrc );
Returns a list that is vLstSrc with the elements in reverse order
- vLstSrc: source list to reverse
Smaller Code:
- LSO: 156 Bytes
- MONO: 512 Bytes
list uListReverse( list vLstSrc ){
integer vIntCnt = (vLstSrc != []);
while (vIntCnt){
vLstSrc += llList2List( vLstSrc, (vIntCnt = ~-vIntCnt), vIntCnt );
vLstSrc = llDeleteSubList( vLstSrc, vIntCnt, vIntCnt );
}
return vLstSrc;
}
/*//-- 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 ] //*/
/*//-- --//*/
Faster Code:
- LSO: 160 Bytes
- MONO: 512 Bytes
list uListReverse( list vLstSrc ){
integer vIntCnt = (vLstSrc != []);
while (vIntCnt){
vLstSrc += llList2List( vLstSrc, (vIntCnt = ~-vIntCnt), vIntCnt );
}
return llList2List( vLstSrc, (vLstSrc != []) >> 1, -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 ] //*/
/*//-- --//*/
Caveats
- The "Faster" version doubles the list size internally, and is more likely to cause a stack/heap collision(script crash) with large lists and/or limited free memory
Notes
- This function is a companion to llListSort.