Next:
Text::Wigwam::Library::Struct
Previous:
Text::Wigwam::Library::Procedure
 [Table of Contents][Text::Wigwam Index]

Text::Wigwam::Library::Sets



NAME

Text::Wigwam::Library::Sets #intersection, #set_minus, #symdiff, #symmetric_difference, #union

Description

This library provides directives which are useful for performing operations on data sets.

Usage

The directives within this library can be imported into specific branches of the directive tree (which transcends from Text::Wigwam::Directives) via plug-ins or modules using one of the following techniques.

 package Text::Wigwam::Directives::some::arbitrary::branch;
 # import everything
 use Text::Wigwam::Library::Sets qw/:all/;

 package Text::Wigwam::Directives::another::arbitrary::branch;
 # import selectively
 use Text::Wigwam::Library::Sets( qw /
  :intersection
  :set_minus
  :symdiff
  :symmetric_difference
  :union
 / );

Directives

#intersection array1 array2

Returns an array of elements common to both array1 and array2

 [!!
   #join ", " #intersection ( 1 2 3 4 5 6 ) ( 2 4 6 8 10 )
  /* output: 2, 4, 6 */
 !!]

#set_minus array1 array2

Returns an array containing elements from array1 that are not in array2.

 [!!
  #join ", " #set_minus ( 1 2 3 4 5 6 ) ( 2 4 6 8 10 )
  /* output: 1, 3 ,5 */
 !!]

#symdiff array1 array2

Shorthand for #symmetric_difference.

#symmetric_difference array1 array2

Returns an array of elements which exist in either array1 or array2, but not both.

 [!!
  #join ", " #symmetric_difference ( 1 2 3 4 5 6 ) ( 2 4 6 8 10 )
  /* output: 1, 3, 5, 8, 10 */
 !!]

#union array1 array2

Returns an array containing all elements of array1 and array2 without duplicates.

 [!!
  #join ", " #union ( 1 2 3 4 5 6 ) ( 5 6 7 8 9 10 )
  /* output: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 */
 !!]