Skip to content

Commit

Permalink
Merge pull request #253 from AleAndForCode/develop
Browse files Browse the repository at this point in the history
Fix filter impl in Stream combinators #252
  • Loading branch information
noelwelsh authored Dec 20, 2024
2 parents dd0f9ca + 28bd636 commit 4b2b7be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/pages/appendices/acknowledgements.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The members of ScalaBridge London and attendees at various training courses acte
Thanks for the members of the PLT research group who inspired me directly back in the day, and continue to provide inspiration from afar.
Finally, thanks to the following who sponsored my work or contributed with corrections and suggestions:

Aleksandr Andreev,
Charles Adetiloye,
Johanna Odersky,
Lunfu Zhong,
Expand Down
8 changes: 4 additions & 4 deletions src/pages/codata/structural.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ trait Stream[A] {

def tail: Stream[A] = {
def loop(stream: Stream[A]): Stream[A] =
if pred(stream.head) then stream.tail
if pred(stream.head) then stream.tail.filter(pred)
else loop(stream.tail)

loop(self)
Expand Down Expand Up @@ -369,7 +369,7 @@ trait Stream[A] {

def tail: Stream[A] = {
def loop(stream: Stream[A]): Stream[A] =
if pred(stream.head) then stream.tail
if pred(stream.head) then stream.tail.filter(pred)
else loop(stream.tail)

loop(self)
Expand Down Expand Up @@ -456,7 +456,7 @@ trait Stream[A] {

def tail: Stream[A] = {
def loop(stream: Stream[A]): Stream[A] =
if pred(stream.head) then stream.tail
if pred(stream.head) then stream.tail.filter(pred)
else loop(stream.tail)

loop(self)
Expand Down Expand Up @@ -546,7 +546,7 @@ def filter(pred: A => Boolean): Stream[A] = {

def tail: Stream[A] = {
def loop(stream: Stream[A]): Stream[A] =
if pred(stream.head) then stream.tail
if pred(stream.head) then stream.tail.filter(pred)
else loop(stream.tail)

loop(self)
Expand Down

0 comments on commit 4b2b7be

Please sign in to comment.