Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dealing with degenerate case for polymod. #3742

Closed
p6rt opened this issue Mar 18, 2015 · 5 comments
Closed

dealing with degenerate case for polymod. #3742

p6rt opened this issue Mar 18, 2015 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Mar 18, 2015

Migrated from rt.perl.org#124104 (status was 'rejected')

Searchable as RT124104$

@p6rt
Copy link
Author

p6rt commented Mar 18, 2015

From @grondilu

Hello,

While writing a version of the Van der Corput sequence in
http://rosettacode.org/wiki/Van_der_Corput_sequence#Perl_6, I've
noticed that 0.polymod($base xx *) returns nothing and I thought this is
wrong.

I suggest the attached patch in order to have polymod return zero
whenever self is zero.

@p6rt
Copy link
Author

p6rt commented Mar 18, 2015

From @grondilu

0001-dealing-with-degenerate-case-for-polymod.patch
From 75f1b01e951270173dc3a6d04dad18c4de9c99ac Mon Sep 17 00:00:00 2001
From: "L. Grondin" <grondilu@yahoo.fr>
Date: Wed, 18 Mar 2015 08:16:59 +0100
Subject: [PATCH] dealing with degenerate case for polymod

---
 src/core/Int.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/core/Int.pm b/src/core/Int.pm
index f79330d..723c646 100644
--- a/src/core/Int.pm
+++ b/src/core/Int.pm
@@ -64,6 +64,7 @@ my class Int does Real { # declared in BOOTSTRAP
     # If self is Int, we assume mods are Ints also.  (div fails otherwise.)
     # If do-not-want, user should cast invocant to proper domain.
     method polymod(Int:D: *@mods) {
+        return 0 if self == 0;
         my $more = self;
         my $inf = @mods.elems == Inf;
         fail X::OutOfRange.new(what => 'invocant to polymod', got => $more, range => "0..*") if $more < 0;
-- 
2.1.4

@p6rt
Copy link
Author

p6rt commented May 10, 2016

From @coke

Sorry for the delay in responding.

This patch no long applies cleanly. If you would still like to pursue this issue, please submit a PR to the rakudo github project, which will make it easier to review and apply.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented May 10, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 10, 2016

@coke - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed May 10, 2016
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant