XLISP union

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# union

Type: | - | Lisp function (closure)
Source: | - | xm.lsp

## Syntax

(union list1 list2)
  listN - a list of symbols or numbers
  returns - the union of list1 and list2

In Nyquist, 'union' is implemented as a Lisp function:

    (defun union (a b)
      (let (result)
        (dolist (elem a)
          (if (not (member elem result)) (push elem result)))
        (dolist (elem b)
          (if (not (member elem result)) (push elem result)))
        result))

## Description

The 'union' function computes the union of two lists. The result is a list containing all elements of both lists, where every element appears exactly once.

## Examples

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference