On Wednesday, January 26, 2000 9:12 AM, Joe Fasel [SMTP:[EMAIL PROTECTED]] wrote:
> 
> 
> The call some have made for the tightest possible error
> checking also has merit, however.  That would suggest
> these definitions:
> 
> > takeExactly 0 _ = []
> > takeExactly (n+1) (x:xs) = x : takeExactly n xs
> > takeExactly _ _ = undefined
> 
> > dropExactly 0 xs = xs
> > dropExactly (n+1) (_:xs) = dropExactly n xs
> > dropExactly _ _ = undefined
> 
> > splitAtExactly n xs = (takeExactly n xs, dropExactly n xs)
> 
> I would say that the more loosely-defined functions definitely
> belong in the library and that it is a matter of taste whether
> or not to include the tighter ones.

We have seen various proposals about what laws should hold wrt
take and drop. I think there is a reasonable presumption that the 
following  very simple laws should hold first:

length (take n xs) === n
length (drop n xs) === length xs -n

This supports Joe's takeExactly/dropExactly definitions.

--brian

Reply via email to