lib.lists.{findFirstIndex,commonPrefix}: init#243520
Conversation
fricklerhandwerk
left a comment
There was a problem hiding this comment.
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 <[email protected]>
c12fae5 to
d5a90ac
Compare
fricklerhandwerk
left a comment
There was a problem hiding this comment.
Very elegant, such compose, many wow.
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