Yep, the "sort only to get head" trick only works fully with selection sort, where it reduces complexity from O(n^2) to O(n) (reduces to a simple max/min). But it also confers some advantage in the case of standard merge sort: the last two sorted sublists will not be merged.
Regarding "repeat", I find it pretty much awesome that it is implemented as a circular linked list with a single element, as in:
repeat x = xs where xs = x : xs
which ensures that it will take up constant space no matter how "far" in it is evaluated.
Regarding "repeat", I find it pretty much awesome that it is implemented as a circular linked list with a single element, as in:
which ensures that it will take up constant space no matter how "far" in it is evaluated.