Name

union — Unions of lists

Synopsis

list union ( list LIST1 ,
  list LIST2 );
 

Parameters

list LIST1

First List

list LIST2

Second List

Return

list

Description

Interprets two lists as sets and returns a new list that has all elements of the first list and all of the second list. Identical elements are merged. The order of the elements in the new list is preserved. Elements of l1 are prior to elements from l2. nil as either argument makes the result nil too.

WARNING: quadratic complexity so far

Usage

  union ([1, 2], [3, 4]) -> [1, 2, 3, 4]
  union ([1, 2, 3], [2, 3, 4]) -> [1, 2, 3, 4]
  union ([1, 3, 5], [1, 2, 4, 6]) -> [1, 3, 5, 2, 4, 6]