3 ms·
I can't find it now, but there is this article/blog somewhere where the author writes only two functions: One tests if a list is sorted and the other generates
by arnarbi 9y ago
I can't find it now, but there is this article/blog somewhere where the author writes only two functions: One tests if a list is sorted and the other generates a seemingly unspecified permutation of a list.
Then they combine the two in some simple way, and out pops a sorting function with no "how" specification. Due to laziness, the testing function "drives" how the permutation function picks its elements and the whole thing devolves to selection sort.
If anyone remembers the source for this, please post it.