NAME
FP::HashSet - set operations for hash tables
SYNOPSIS
use FP::HashSet; # ":all";
my $A= array_to_hashset ["a","b","c"];
my $B= array_to_hashset ["a","c","d"];
hashset_to_array hashset_union($A,$B) # -> ["a","b","c","d"]
hashset_to_array hashset_intersection($A,$B) # -> ["a","c"]
hashset_to_array hashset_difference($A,$B) # -> ["b"]
hashset_is_subset($B,$A) # -> false
hashset_is_subset(+{b=>1},$A) # -> true
hashset_size($A) # -> 3
hashset_empty($A) # -> false
hashset_empty(+{}) # -> true
hashset_keys_unsorted($A) # ("a","b","c") or in another sort order;
# *keys* not values, hence always strings.
hashset_keys ($A) # always ("a","b","c") (sorted)
# a la diff tool:
hashset_diff($A,$B) # -> {b=>"-",d=>"+"}
# to treat a hashset as a function:
my $f= hashset_to_predicate ($A);
$f->("a") # -> true
DESCRIPTION
Hashsets are hash tables that are expected to have keys representing the values unambiguously (FP::Array::array_to_hashset will just use the stringification).
Note that hashset_to_array will use the *values* of the hashes, not the keys.