-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Streaming.take(n).toList shouldn't blow up when n+1 is an error #530
Conversation
Current coverage is
|
case Cons(a, lt) => Cons(a, lt.map(_.take(n - 1))) | ||
case Cons(a, lt) => | ||
if (n == 1) Cons(a, Now(Empty())) | ||
else Cons(a, lt.map(_.take(n - 1))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm too fussy, but could we rewrite that line?
Cons(a, if (n == 1) Now(Empty()) else lt.map(_.take(n - 1))
👍 (with-or-without my fussy suggestion honestly) |
A gift for @non.
👍 |
Merge conflicts. Also one nitpicky comment :-) |
@@ -473,7 +473,8 @@ sealed abstract class Streaming[A] { lhs => | |||
if (n <= 0) Empty() else this match { | |||
case Empty() => Empty() | |||
case Wait(lt) => Wait(lt.map(_.take(n))) | |||
case Cons(a, lt) => Cons(a, lt.map(_.take(n - 1))) | |||
case Cons(a, lt) => | |||
Cons(a, if (n ==1) Now(Empty()) else lt.map(_.take(n - 1))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eeeek, space between ==
and 1
:-)
@adelbertc thanks. Hopefully this should pass inspection now :) |
👍 |
1 similar comment
👍 |
Streaming.take(n).toList shouldn't blow up when n+1 is an error
The
Cons(a, lt.map(_.take(n - 1)))
seems reasonable enough, but sincetoList
callslt.value
, this blows up whenlt
is a deferred error.