-
-
Notifications
You must be signed in to change notification settings - Fork 9
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 simplifications for List.take and List.drop #268
Comments
Nice.
Other than those nitpicks, looks good! |
Yes, of course. My bad. This was a bit of a hasty late suggestion. Removed
Fixed! Thanks |
@jfmengels List.drop 2 ([x,y,z] ++ list)
--> z :: list I am not personally sure about List.take 2 (x :: list)
--> x :: List.take 1 list It should be better for performance, but i think maybe the resulting code is a bit more unclear. |
More simplifications for List.take and List.drop
Some suggestions for List.take and List.drop simplifications.
I think take and map are functions that are used a lot, so new rules would probably be applied in many codebases 🚀
(
n
is refering to the Int argument , as inList.take n list
)List.drop with negative n - ✅ #270
Literal lists with size <= n (drop: ✅ #270)
List.repeat with non-negative n <= repeat arg
List.range with size >= n
Generalization question
Some of these can be generalized more, f.ex.
But I am not sure about the clarity of the resulting code and also about how it will impact further simplifications.
So I went with the simpler one. Open for suggestions
Feedback and tips welcome! And of course more suggestions and corrections.
I can probably look into implementing most of these myself.
The text was updated successfully, but these errors were encountered: