intersect3

Command in the TclX package to perform set differences between two lists. It returns a list of three lists: the first element returned is everything in the first list that isn't in the second list; the second element returned is the intersection of the two lists; the third element returned is everything in the second list that isn't in the first list. The returned lists will be sorted.

Usage:

intersect3 lista listb

Example:

  package require Tclx
  intersect3 {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.


SetOps, Intersect3

Additional list functions - there is a nice implementation on this page attributed to David Easton