Skip to content

Commit

Permalink
Fix filter impl in Stream combinators scalawithcats#252
Browse files Browse the repository at this point in the history
  • Loading branch information
AleAndForCode committed Sep 16, 2024
1 parent 8f42d48 commit 69d1611
Showing 1 changed file with 4 additions and 4 deletions.
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 69d1611

Please sign in to comment.