Idris2/tests/idris2/with/with011/WithImplicits.idr
2023-09-07 14:57:22 +01:00

10 lines
332 B
Idris

import Data.Vect
import Data.Vect.Views.Extra
mergeSort : Ord a => {n : _} -> Vect n a -> Vect n a
mergeSort input with (splitRec input)
mergeSort [] | SplitRecNil = []
mergeSort [x] | SplitRecOne = [x]
mergeSort (xs ++ ys) | (SplitRecPair {xs} {ys} xs_rec ys_rec) =
merge (mergeSort xs | xs_rec) (mergeSort ys | ys_rec)