ListXxorY

From Second Life Wiki
Revision as of 16:03, 12 July 2008 by Chaz Longstaff (talk | contribs) (New page: {{LSL Header}} __NOTOC__ <div id="box"> == Function: list ListXnotY(list {{LSL Param|lx}}, list {{LSL Param|ly}}); == <div style="padding: 0.5em;"> Returns a new list, composed...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Function: list ListXnotY(list lx, list ly);

Returns a new list, composed of elements that were in either original script, but not both.

Note: This is not the same as getting rid duplicates by preserving just one of each duplicated item. It goes further, and removes both items.


<lsl> list ListXxorY(list lx, list ly) { // return elements that are in X or Y but not both

   return ListXnotY( lx, ly) + ListXnotY( ly, lx);

} </lsl>


Example:

<lsl> list l1 = ["a","b","c","d"]; list l2 = ["a","1","b","2","c","3"];

default{

  state_entry() {
     llSay(0, "Elements that are in x list or y list but not both: " + llList2CSV(ListXxorY(l1,l2)));
     //will say: d, 1, 2, 3
  }

} </lsl>

Posted with the kind permission of Very Keynes, who originated this script June 2007 in the SL scripters forum http://forums.secondlife.com/showthread.php?t=194138