Skip to content

Commit

Permalink
🧩 [refactor]: Better mergeSort impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolyp committed Sep 25, 2023
1 parent a1de82e commit bc4e250
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions fluid/example/mergeSort.fld
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ let split [] = ([], []);
};

mergesort xs =
match xs as {
[] -> xs;
[x] -> xs;
x : y : _ ->
let (ys, zs) = split xs in
merge (mergesort ys) (mergesort zs)
}
if length xs < 2
then xs
else
let (ys, zs) = split xs in
merge (mergesort ys) (mergesort zs)
in
mergesort [3, 1, 2]

0 comments on commit bc4e250

Please sign in to comment.