[Haskell-cafe] Re: Is "take" behaving correctly?
Henning Thielemann
lemming at henning-thielemann.de
Wed Sep 12 12:34:22 EDT 2007
On Wed, 12 Sep 2007, PR Stanley wrote:
> I quite like the argument that take is a total function and as such all its
> return values are from teh specificed range. I can also see the logic in
> take n [] = [] where n > 0
> taking n from nothing, or the empty set, returns nothing!
> The same should apply to head and tail. head or tail of [] should be [].
Today you can use (drop 1) which has this property. However I consider it
bad style that 'tail' and 'drop' behave so differently, and that one has
to write (drop 1) when in fact (tailSafe) is meant. People reading (drop
1) in a program may assume, that the programmer was a newbie, who was not
aware of 'tail'.
More information about the Haskell-Cafe
mailing list