[perl-Language-Functional] Import

Petr Pisar ppisar at fedoraproject.org
Wed Jun 15 13:23:09 UTC 2011


commit 6688733d62b6672ce721a1ea545a2aa2c2570b75
Author: Petr Písař <ppisar at redhat.com>
Date:   Wed Jun 15 15:22:41 2011 +0200

    Import

 .gitignore                                         |    1 +
 ...nal-0.04-Fix-any-and-all-on-infinite-list.patch |   61 ++++++++++++++++++++
 perl-Language-Functional.spec                      |   58 +++++++++++++++++++
 sources                                            |    1 +
 4 files changed, 121 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..53df3ee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/Language-Functional-0.04.tar.gz
diff --git a/perl-Language-Functional-0.04-Fix-any-and-all-on-infinite-list.patch b/perl-Language-Functional-0.04-Fix-any-and-all-on-infinite-list.patch
new file mode 100644
index 0000000..1aecf01
--- /dev/null
+++ b/perl-Language-Functional-0.04-Fix-any-and-all-on-infinite-list.patch
@@ -0,0 +1,61 @@
+From 73c916ba63070d9076b1286220ea7544d24925bc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar at redhat.com>
+Date: Tue, 14 Jun 2011 18:19:25 +0200
+Subject: [PATCH] Fix any() and all() on infinite list
+
+---
+ Functional.pm |   31 ++++++++++++++++++++++++-------
+ 1 files changed, 24 insertions(+), 7 deletions(-)
+
+diff --git a/Functional.pm b/Functional.pm
+index 78cfadd..493979c 100644
+--- a/Functional.pm
++++ b/Functional.pm
+@@ -1320,9 +1320,18 @@ In Haskell:
+ 
+ sub any(&$) {
+   my($p, $xs) = @_;
+-  map {
+-    return 1 if $p->($_);
+-  } @{$xs};
++  my $n = 0;
++  my $size = $#{$xs};
++  while ($n <= $size) {
++    return 1 if $p->($xs->[$n]);
++    $n++;
++  }
++  if ($size == $Language::Functional::INFINITE
++      or $size == $Language::Functional::INFINITE - 1
++  ) {
++    confess "Evaluating predicate on inifinite number of elements " .
++      "would never end!";
++  }
+   return 0;
+ }
+ 
+@@ -1345,10 +1354,18 @@ In Haskell:
+ 
+ sub all(&$) {
+   my($p, $xs) = @_;
+-  map {
+-    my $x = $_;
+-    return 0 if not $p->($x);
+-  } @{$xs};
++  my $n = 0;
++  my $size = $#{$xs};
++  while ($n <= $size) {
++    return 0 if not $p->($xs->[$n]);
++    $n++;
++  }
++  if ($size == $Language::Functional::INFINITE
++      or $size == $Language::Functional::INFINITE - 1
++  ) {
++    confess "Evaluating predicate on inifinite number of elements " .
++      "would never end!";
++  }
+   return 1;
+ }
+ 
+-- 
+1.7.5.4
+
diff --git a/perl-Language-Functional.spec b/perl-Language-Functional.spec
new file mode 100644
index 0000000..9945eee
--- /dev/null
+++ b/perl-Language-Functional.spec
@@ -0,0 +1,58 @@
+Name:           perl-Language-Functional
+Version:        0.04
+Release:        1%{?dist}
+Summary:        Module which makes Perl slightly more functional
+License:        GPL+ or Artistic
+Group:          Development/Libraries
+URL:            http://search.cpan.org/dist/Language-Functional/
+Source0:        http://www.cpan.org/authors/id/L/LB/LBROCARD/Language-Functional-%{version}.tar.gz
+#CPAN RT #20698
+Patch0:         %{name}-0.04-Fix-any-and-all-on-infinite-list.patch
+BuildArch:      noarch
+BuildRequires:  perl(ExtUtils::MakeMaker)
+# Tests:
+BuildRequires:  perl(Exporter)
+BuildRequires:  perl(Test)
+BuildRequires:  perl(Test::More)
+BuildRequires:  perl(Test::Pod) >= 1.14
+BuildRequires:  perl(Tie::Array)
+Requires:       perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
+
+%{?filter_setup:
+%filter_from_provides /^perl(InfiniteList)/d
+%filter_setup
+}
+
+%description
+Perl already contains some functional-like functions, such as map and grep.
+The purpose of this module is to add other functional-like functions to
+Perl, such as foldl and foldr, as well as the use of infinite lists.
+
+%prep
+%setup -q -n Language-Functional-%{version}
+%patch0 -p1 -b .fix_any_all
+
+%build
+%{__perl} Makefile.PL INSTALLDIRS=vendor
+make %{?_smp_mflags}
+
+%install
+make pure_install PERL_INSTALL_ROOT=$RPM_BUILD_ROOT
+find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} \;
+find $RPM_BUILD_ROOT -depth -type d -exec rmdir {} 2>/dev/null \;
+%{_fixperms} $RPM_BUILD_ROOT/*
+
+%check
+make test
+
+%files
+%doc CHANGES README
+%{perl_vendorlib}/*
+%{_mandir}/man3/*
+
+%changelog
+* Tue Jun 14 2011 Petr Pisar <ppisar at redhat.com> 0.04-1
+- Specfile autogenerated by cpanspec 1.78.
+- Remove BuildRoot and defattr stuff
+- Do not provides private module InfiniteList
+- Fix any() and all() implementation (CPAN RT #20698)
diff --git a/sources b/sources
index e69de29..e2fb922 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+6eb8a6ae99971ad3c8dfa3bd88792710  Language-Functional-0.04.tar.gz



More information about the perl-devel mailing list