Created
August 16, 2017 17:20
-
-
Save haodemon/5a69c80f51fac8da025bd9ad55b89c4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use 5.016; | |
use strict; | |
use warnings; | |
sub array_minus(\@\@) { | |
my %e = map{ $_ => undef } @{$_[1]}; | |
return grep( !exists($e{$_}), @{$_[0]} ); | |
} | |
my @a = (1, 2); | |
my @b = (1, 2, 3); | |
say array_minus @b, @a; | |
say array_minus @a, @b; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment