Skip to content

Commit bd80979

Browse files
authored
Merge pull request #63 from JohanWiltink/main
add compare-by
2 parents 30c73be + 0969073 commit bd80979

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/scott-lists/solution.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,13 @@ insert-by = \ le x xs . uncurry append (second (cons x) (span (C le x) xs))
202202
sort-by = \ le . foldr (insert-by le) nil
203203
# has all sorts of bad implementation details, but it's simple
204204

205+
# compare-by :: (a -> a -> Ordering) -> List a -> List a -> Ordering
206+
compare-by = \ cmp xs ys . xs (ys EQ LT)
207+
\ x xs . ys GT
208+
\ y ys . cmp x y LT
209+
(compare-by cmp xs ys)
210+
GT
211+
205212
# reverse :: List a -> List a
206213
reverse = foldl (C cons) nil
207214

0 commit comments

Comments
 (0)