summaryrefslogtreecommitdiff
path: root/lib/Automake/General.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Automake/General.pm')
-rw-r--r--lib/Automake/General.pm20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/Automake/General.pm b/lib/Automake/General.pm
index 32f5c8db7..aa2de38b8 100644
--- a/lib/Automake/General.pm
+++ b/lib/Automake/General.pm
@@ -23,7 +23,7 @@ use File::Basename;
use vars qw (@ISA @EXPORT);
@ISA = qw (Exporter);
-@EXPORT = qw (&uniq $me);
+@EXPORT = qw (&uniq &none $me);
# Variable we share with the main package. Be sure to have a single
# copy of them: using 'my' together with multiple inclusion of this
@@ -66,5 +66,23 @@ sub uniq (@)
return wantarray ? @res : "@res";
}
+# $RES
+# none (&PRED, @LIST)
+# ------------
+# Return 1 when no element in LIST satisfies predicate PRED otherwise 0.
+sub none (&@)
+{
+ my ($pred, @list) = @_;
+ my $res = 1;
+ foreach my $item (@list)
+ {
+ if ($pred->($item))
+ {
+ $res = 0;
+ last;
+ }
+ }
+ return $res;
+}
1; # for require