
Philip Scott
So I puzzled for a little bit about how to do this in the most Haskelly way and I thought of this
months = concat (range (Jan, Dec) : months)
Which should work, right**
** though I am pretty sure this is the Wrong Way to do this. I suspect concat takes O(n) time - more elegant approaches would be welcomed!
Nobody seem to relate to that point. No, it's not O(n) time. It's O(1) time. It's just one lazy definition. The _access_ is O(n) and the definition kicks in at the right time while riding along with the access - take, drop or whatever - along the list. It is always just taking one head element at a time off the first list, if not empty, or else switching to the next one - and feeding that element to list access. If it's not eliminated completely by compilation. :)