OpenMusic Reference
x-diff
x-diff
(sets module) -- returns a list wth all the elements present in l1? and list but not in l2? .
Syntax
x-diff l1? l2? &optional test key &rest list
Inputs
name | data type(s) | comments |
---|---|---|
l1? | a list or tree | |
l2? | a list or tree | |
test | a function name or lambda function | optional; the function with which to compare the two lists. Defaults to ‘equal’ |
key | a function name or lambda function | optional; a function to apply to the lists before comparison. Defaults to ‘identity’ |
list | list | optional, extensible; additional lists to be compared. |
Output
output| data type(s)| comments
—|—|—
first| a list| a single list, containing the elements present in l1? but
not l2? but not both. If used with list , returns any elements
present in l1? , but not l2? and any list s.
Description
Each element of l1? is compared to all the elements of the other list(s) and passed to the output only if it does not equal any of them. This box is similar in function to x-xor , except that it only passes elements of l1? .
If the optional test argument is added, the lists can be compared according to any predicate. The default value of test is ‘equal. Only elements in l1? that return nil in comparison with every element in the other list (according to the predicate) are returned in the result list. Since the default comparison returns t if the elements are equal, only elements which apppear only in l1? are passed.
If the key argument is included (the default function is identity ), the function at key is first evaluated using each of l1? ‘s and l2? ‘s elements as input, and then the lists are compared according to the test on the results of the function. test and key may be either the name of a predicate function or a connected function or subpatch icon in lambda mode.
Additional lists can be compared by adding list inputs.
![]() |
This function is not commutative; only elements which apppear only in l1? are passed. See below.
—|—
Examples
The non-commutative property of x-diff .
This finds the elements belonging to the first set but not the second:
? OM->(1 5 1) . Note the order of the elements.
Here we switch the outputs. The result list is not the same since only elements of the first list could pass: ? OM->(7) .
Prev | Home | Next |
---|---|---|
x-append | Up | x->dx |