All pastes #77896 Raw Edit

Mine

public text v1 · immutable
·published 2006-07-03 15:10 UTC
rendered paste body
insert = pure (ins:T, list:[T]) -> ([T]) ?
	return [ins] if list.empty;
	if ins < list.head ?
		return [ins] ++ list;
	else
		return [list.head] ++ insert(ins, list.tail);
	.
.

insert_sort_impl = pure (list:[T], done[T] = []) -> ([T]) ?
	return done if list.empty;
	return insert_sort_impl(list.tail, insert(list.head, done));		
.

insert_sort = pure(list:[T]) -> ([T]) ?
	return list.insert_sort_impl;
.