Skip to content

Commit

Permalink
tiny optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrt-x committed Dec 21, 2023
1 parent 2f69163 commit d3a8a79
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/Sorts/New3WM.hs
Expand Up @@ -13,7 +13,7 @@ sortBy cmp = mergeAll . sequences
sequences xs = [xs]

descending a as (b:bs)
| a `cmp` b == GT = descending b (a:as) bs
| a `cmp` b /= LT = descending b (a:as) bs
descending a as bs = (a:as): sequences bs

ascending a as (b:bs)
Expand All @@ -33,7 +33,7 @@ sortBy cmp = mergeAll . sequences
x `gt` y = x `cmp` y == GT

merge as@(a:as') bs@(b:bs')
| a `gt` b = b : merge as bs'
| a `gt` b = b : merge as bs'
| otherwise = a : merge as' bs
merge [] bs = bs
merge as [] = as
Expand Down

0 comments on commit d3a8a79

Please sign in to comment.