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

feat: implement dropWhile function #21

Merged
merged 1 commit into from
Oct 17, 2023
Merged

feat: implement dropWhile function #21

merged 1 commit into from
Oct 17, 2023

Conversation

geminicaprograms
Copy link
Contributor

@geminicaprograms geminicaprograms commented Oct 16, 2023

Drops elements from the source as long as the predicate is satisfied. Note that if the predicate fails then subsequent elements are no longer dropped even if they could still satisfy it.
Examples:

  Source.empty[Int].dropWhile(_ > 3).toList          // List()
  Source.fromValues(1, 2, 3).dropWhile(_ < 3).toList // List(3)
  Source.fromValues(1, 2, 1).dropWhile(_ < 2).toList // List(2, 1)

import ox.*

class SourceOpsDropWhileTest extends AnyFlatSpec with Matchers {
behavior of "Source.drop"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: dropWhile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

s.dropWhile(_ > 0).toList shouldBe List.empty
}

it should "drop elements from the source while predicate is true" in scoped {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: If I understand correctly in Adam's review to another PR, scoped should be replaced with supervised

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Drops elements from the source as long as the predicate is satisfied.
Note the if predicate fails then subsequent elements are no longer
dropped even if they could still satisfy it. Examples:

  Source.empty[Int].dropWhile(_ > 3).toList          // List()
  Source.fromValues(1, 2, 3).dropWhile(_ < 3).toList // List(3)
  Source.fromValues(1, 2, 1).dropWhile(_ < 2).toList // List(2, 1)
@adamw adamw merged commit fe9d6c9 into feat_drop Oct 17, 2023
4 checks passed
@adamw adamw deleted the feat_dropWhile branch February 21, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants