Noogλe
search input
Function of the day
Split type into two subtypes by predicate
p, take all elements of the first subtype to be less than all the elements of the second subtype, compare elements of a single subtype withyesandnorespectively.Inputs
p-
Predicate
yes-
Comparison function if predicate holds for both values
no-
Comparison function if predicate holds for neither value
a-
First value to compare
b-
Second value to compare
Type
splitByAndCompare :: (a -> Bool) -> (a -> a -> Int) -> (a -> a -> Int) -> (a -> a -> Int)Examples
lib.trivial.splitByAndCompareusage examplelet cmp = splitByAndCompare (hasPrefix "foo") compare compare; in cmp "a" "z" => -1 cmp "fooa" "fooz" => -1 cmp "f" "a" => 1 cmp "fooa" "a" => -1 # while compare "fooa" "a" => 1