ListCompare

From Second Life Wiki

Jump to: navigation, search

Template:Needs Translation/LSL/de Template:Needs Translation/LSL/es Template:Needs Translation/LSL/el Template:Needs Translation/LSL/fr Template:Needs Translation/LSL/he Template:Needs Translation/LSL/it Template:Needs Translation/LSL/ja Template:Needs Translation/LSL/ko Template:Needs Translation/LSL/nl Template:Needs Translation/LSL/hu Template:Needs Translation/LSL/no Template:Needs Translation/LSL/da Template:Needs Translation/LSL/sv Template:Needs Translation/LSL/tr Template:Needs Translation/LSL/pl Template:Needs Translation/LSL/pt Template:Needs Translation/LSL/ru Template:Needs Translation/LSL/uk Template:Needs Translation/LSL/zh-Hans Template:Needs Translation/LSL/zh-Hant

Contents

Summary

Function: integer ListCompare( list a, list b );

Efficiently compares two lists for equality (same contents).
Returns an integer TRUE if the lists are equal, FALSE if not.

• list a The first list to compare.
• list b The second list to compare.

Examples

integer r = ListCompare([1, 2.0, "3"], [1, 2.0, "3"]); // Returns TRUE
integer s = ListCompare([1, 2.0, 3], [1, 2.0, "3"]);   // Returns FALSE
integer t = ListCompare([], [1, 2.0, "3"]);            // Returns FALSE

Deep Notes

Implementation

integer ListCompare(list a, list b) {
    integer aL = a != [];
    if (aL != (b != [])) return 0;
    if (aL == 0)         return 1;
 
    return !llListFindList((a = []) + a, (b = []) + b);
}
Personal tools
In other languages