-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
lib.lists.{findFirstIndex,commonPrefix}
: init
#243520
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the minimality of all this, a lot.
Just brainstorming here: what do you think about extracting out
Not sure about the performance of this or if |
Thinking about this a little more, the following can also be a route if We use your algorithm and create the more general:
and then use that to define:
and finally:
where forming that last predicate depends on some design decisions (like does |
This seems like a useful function to factor out. |
a07eb3d
to
8b98e4e
Compare
@tjni Nice idea! This turned out to work out really well since I was able to reuse a lot of code. I removed |
lib.lists.{commonPrefix,commonPrefixLength}
: initlib.lists.{findFirstIndex,commonPrefix}
: init
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
c12fae5
to
d5a90ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very elegant, such compose, many wow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome!
d5a90ac
to
7f61b01
Compare
Description of changes
Adds two new functions:
lib.lists.findFirstIndex :: (a -> bool) -> Any -> [a] -> (Int | Any)
: Find the first index in the list matching the specified predicate or return a default if no such element exists.lib.lists.commonPrefix :: [ a ] -> [ a ] -> [ a ]
: The common prefix of two lists:This is distantly part of the path library effort, in order to be able to work with lists of path components. Relates to #243511
This work is sponsored by Antithesis ✨
Things done