# New Ticket Created by grond...@yahoo.fr
# Please include the string: [perl #124104]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=124104 >
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.
>From 75f1b01e951270173dc3a6d04dad18c4de9c99ac Mon Sep 17 00:00:00 2001
From: "L. Grondin" <grond...@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