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

More List.drop simplifications #270

Merged
merged 3 commits into from
Oct 10, 2023

Conversation

lue-bird
Copy link
Collaborator

Some simplifications from #268 and more

List.drop -1 list
--> list

List.drop 3 [ a, b ] -- including List.singleton etc where we can determine the size
--> []

List.drop 2 [ a, b, c ]
--> [ c ]

@lue-bird lue-bird added the enhancement New feature or request label Oct 10, 2023
@@ -7118,7 +7118,7 @@ a = List.drop 0 list
|> Review.Test.run ruleWithDefaults
|> Review.Test.expectErrors
[ Review.Test.error
{ message = "List.drop 0 will always return the same given list"
{ message = "List.drop with count 0 will always return the same given list"
Copy link
Owner

Choose a reason for hiding this comment

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

I feel like the previous error message was better 🤷‍♂️

Copy link
Owner

@jfmengels jfmengels left a comment

Choose a reason for hiding this comment

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

Nice. I'm unsure about the count error message, but let's go with that if you think it's better.

@lue-bird
Copy link
Collaborator Author

That's just a side effect of using the callWithNonPositiveIntCheckErrorSituation helper. I also wouldn't say that the new message for 0 specifically is better but it's fine in my eyes.

@jfmengels jfmengels merged commit 0fcc784 into jfmengels:main Oct 10, 2023
2 checks passed
@lue-bird lue-bird deleted the List.drop-simplifications branch October 10, 2023 12:13

So for example

Array.drop 3 (Array.repeat 2 a) --> []
Copy link
Contributor

Choose a reason for hiding this comment

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

I think Array does not have a drop-function, only slice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants