Idris2/tests/idris2/with011/WithImplicits.idr

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)