User Tools

A PCRE internal error occured. This might be caused by a faulty plugin

====== Function UNION, NUNION ====== ====Syntax==== * **union ** //list-1 list-2 ''&key'' key test test-not// → //result-list// * **nunion** //list-1 list-2 ''&key'' key test test-not// → //result-list// ====Arguments and Values==== * //list-1// - a //[[CL:Glossary:proper list]]//. * //list-2// - a //[[CL:Glossary:proper list]]//. * //test// - a //[[CL:Glossary:designator]]// for a //[[CL:Glossary:function]]// of two //[[CL:Glossary:argument|arguments]]// that returns a //[[CL:Glossary:generalized boolean]]//. * //test-not// - a //[[CL:Glossary:designator]]// for a //[[CL:Glossary:function]]// of two //[[CL:Glossary:argument|arguments]]// that returns a //[[CL:Glossary:generalized boolean]]//. * //key// - a //[[CL:Glossary:designator]]// for a //[[CL:Glossary:function]]// of one [[CL:Glossary:argument]], or **[[CL:Constant Variable:nil]]**. * //result-list// - a //[[CL:Glossary:list]]//. ====Description==== **union** and **nunion** return a //[[CL:Glossary:list]]// that contains every element that occurs in either //list-1// or //list-2//. For all possible ordered pairs consisting of one element from //list-1// and one element from //list-2//, **'':test''** or **'':test-not''** is used to determine whether they //[[CL:Glossary:satisfy the test]]//. The first argument to the **'':test''** or **'':test-not''** function is the part of the element of //list-1// extracted by the **'':key''** function (if supplied); the second argument is the part of the element of //list-2// extracted by the **'':key''** function (if supplied). The argument to the **'':key''** function is an element of //list-1// or //list-2//; the return value is part of the supplied element. If **'':key''** is not supplied or **[[CL:Constant Variable:nil]]**, the element of //list-1// or //list-2// itself is supplied to the **'':test''** or **'':test-not''** function. For every matching pair, one of the two elements of the pair will be in the result. Any element from either //list-1// or //list-2// that matches no element of the other will appear in the result. If there is a duplication between //list-1// and //list-2//, only one of the duplicate instances will be in the result. If either //list-1// or //list-2// has duplicate entries within it, the redundant entries might or might not appear in the result. The order of elements in the result do not have to reflect the ordering of //list-1// or //list-2// in any way. The result //[[CL:Glossary:list]]// may be **[[CL:Functions:eq]]** to either //list-1// or //list-2// if appropriate. ====Examples==== <blockquote> (union '(a b c) '(f a d)) <r>(A B C F D) //or// (B C F A D) //or// (D F A B C)</r> (union '((x 5) (y 6)) '((z 2) (x 4)) :key #'[[CL:Functions:car]]) <r>((X 5) (Y 6) (Z 2)) //or// ((X 4) (Y 6) (Z 2))</r> ([[CL:Macros:defparameter]] //*list-1*// ([[CL:Functions:list]] 1 2 '(1 2) "a" "b")) <r>*LIST-1*</r> ([[CL:Macros:defparameter]] //*list-2*// ([[CL:Functions:list]] 2 3 '(2 3) "B" "C")) <r>*LIST-2*</r> (nunion //*list-1*// //*list-2*//) <r>(1 (1 2) "a" "b" 2 3 (2 3) "B" "C") //or// (1 2 (1 2) "a" "b" "C" "B" (2 3) 3)</r> </blockquote> ====Side Effects==== **nunion** is permitted to modify any part, //[[CL:Glossary:car]]// or //[[CL:Glossary:cdr]]//, of the //[[CL:Glossary:list structure]]// of //list-1// or //list-2//. ====Affected By==== None. ====Exceptional Situations==== Should be prepared to signal an error of type type-error if //list-1// and //list-2// are not //[[CL:Glossary:proper list|proper lists]]//. ====See Also==== **[[CL:Functions:intersection|Function INTERSECTION]]**, {\secref\ConstantModification}, {\secref\TraversalRules} ====Example Implementation==== To be done. ====Notes==== The **'':test-not''** parameter is deprecated. Since the **nunion** side effect is not required it should not be used in for-effect-only positions in portable code. \issue{REMF-DESTRUCTION-UNSPECIFIED:X3J13-MAR-89} \issue{MAPPING-DESTRUCTIVE-INTERACTION:EXPLICITLY-VAGUE} \issue{CONSTANT-MODIFICATION:DISALLOW} \issue{TEST-NOT-IF-NOT:FLUSH-ALL}