partition_impl : pure (list:@T, pivot:T, ret:(2$@T))->(2$@T) = return ret if !list; (h,t) = *list; if h < pivot ? return partition_impl( t, pivot, ( [0]ret::h, [1]ret ) ); else ? return partition_impl( t, pivot, ( [0]ret, [1]ret::h ) ); . . partition : pure (list:@T, pivot:T)->(2$@T) = return partition_impl( list, pivot, (2$[]) ); . quick_sort : pure (list:@T)->(@T) = if !list ? return list;. (h,t) = *list; if !t ? return list;. (pre,post) = partition(t, h); if !pre ? return h::quicksort(post); else if !post ? return quicksort(pre)::h; else return quicksort(pre)::h::quicksort(post); . . (14:22:41) pfeilspitze> I wrote up quick, insertion, selection, and merge sorts before starting on the interpreter (14:23:08) pfeilspitze> they've gone through a number of revisions as I adapt the syntax (14:23:41) pfeilspitze> for parsing ease, grammar simplification, and typing convenience (14:24:33) pfeilspitze> I was originally using index@tuple for the get-nth-element syntax (14:24:43) pfeilspitze> but it turned out to be really annoying to type (14:25:00) pfeilspitze> yeah, and I need to get off to circuit analysis class