Version 4 of union

Updated 2007-11-07 19:50:00 by GPS

Procedure to return the logical union of the two specified lists. Any duplicate elements are removed.

Usage:

  union lista listb

Example:

  package require Tclx
  union {a b c d e} {d e d f g c} ;# ==> a b c d e f g

This functionality exists in tcllib in the struct::set package.


I believe this can also be implemented in Tcl without an extension via:

 proc union {a b} {
  lsort -unique [concat $a $b]
 }

Category Command, a part of Tclx