I made a simple insertion sort in F#, it uses a tail recursive shift
function that attempts to shift an element in a list until it is in the right order. Would like some feedback on the design.
let insertionSort xs =
let shiftInsert xs x =
let rec shift xs x f =
match xs with
| [] ->
f() @ [x]
| hd::tl ->
if x < hd then
f() @ x::hd::tl
else
shift tl x (fun () -> f() @ [hd])
shift xs x (fun () -> [])
List.fold shiftInsert [] xs
@
\$\endgroup\$