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

.polymod implementation assumes all lazy lists are infinite #5327

Closed
p6rt opened this issue May 18, 2016 · 5 comments
Closed

.polymod implementation assumes all lazy lists are infinite #5327

p6rt opened this issue May 18, 2016 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented May 18, 2016

Migrated from rt.perl.org#128176 (status was 'resolved')

Searchable as RT128176$

@p6rt
Copy link
Author

p6rt commented May 18, 2016

From @zoffixznet

When given a lazy list as the argument, .polymod divides until the original number given by the invocant reaches zero. That works when the lazy list is infinite, but when it isn't, we lose the final remainder. This affects both the Int and Real implementations. Here's a sample program demonstrating the issue​:

  say 42.polymod​: 2, 3;
  say 42.polymod​: lazy 2, 3;
 
  say 42.Rat.polymod​: 2, 3;
  say 42.Rat.polymod​: lazy 2, 3;
 
  # OUTPUT​:
  # (0 0 7)
  # (0 0)
  # (0 0 7)
  # (0 0)

@p6rt
Copy link
Author

p6rt commented May 19, 2016

From @jnthn

On Wed May 18 07​:56​:18 2016, cpan@​zoffix.com wrote​:

When given a lazy list as the argument, .polymod divides until the
original number given by the invocant reaches zero. That works when
the lazy list is infinite, but when it isn't, we lose the final
remainder. This affects both the Int and Real implementations. Here's
a sample program demonstrating the issue​:

say 42.polymod​: 2, 3;
say 42.polymod​: lazy 2, 3;

say 42.Rat.polymod​: 2, 3;
say 42.Rat.polymod​: lazy 2, 3;

# OUTPUT​:
# (0 0 7)
# (0 0)
# (0 0 7)
# (0 0)

It's worth noting that Perl 6 doesn't have a concept of infinite lists (that is, doesn't try to track that or make decisions based on it). Rather, a list (or sequence) can be marked lazy (or not). So however this gets changed (if at all), it'll want to be based on deciding what to do in the lazy vs. non-lazy case.

/jnthn

@p6rt
Copy link
Author

p6rt commented May 19, 2016

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

@p6rt
Copy link
Author

p6rt commented Jul 16, 2016

From @zoffixznet

Fixed in rakudo/rakudo@980f496fa8

Tests added in Raku/roast@61160f5640

@p6rt
Copy link
Author

p6rt commented Jul 16, 2016

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jul 16, 2016
@p6rt p6rt added the Bug 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