Mojo::Collection::Role::Set - Set operations for collections
A role for Mojo::Collection objects to provide set operations "diff", "duplicates", "intersect", "sym_diff" and "union".
# [2]
c(2, 3, 5, 7, 11, 13, 17)->with_roles('+Set')
->interset(c(grep { ! $_ % 2 } 1 .. 20))->to_array;
# import
use Mojo::Collection::Role::Set 'set';
# [1, 2, 3, 4, 5]
set(1 .. 5);
Like the Mojo::Collection c()
, this is sugar for creating a collection with this role.
# [1, 2, 3, 4, 5, 6, 7, 8, 9]
c(1 .. 20)->with_roles('+Set')->diff(c(10 .. 30))->to_array;
The values in a Mojo::Collection that are not in the second one.