Ok. so I got it backward. The functionality is still useful and belongs
with take and drop.
The correct definitions would be:
take -2 -- drops the last 2 elements from the list
(takes everything except the last 2 elements)
drop -2 -- grabs the last 2 elements from the list
(drops everything except the last 2 elements)
drop n list | n<0 = drop (length list + n) list
take n list | n<0 = take (length list + n) list
These are also sane definitions..
-Alex-
On Tue, 25 Jan 2000, Brian Boutel wrote:
> On Tuesday, January 25, 2000 8:38 AM, S. Alexander Jacobson [SMTP:[EMAIL PROTECTED]]
>wrote:
> Why not do what python does?
>
> drop -2 -- drops the last 2 elements from the list
> take -2 -- grabs the last 2 elements from the list
>
> take n list | n<0 = drop (length list + n) list
> drop n list | n<0 = take (length list + n) list
>
> [...]
> I think this solution also satisfies Chris Okasaki's:
>
> take n xs ++ drop n xs == xs
>
> (except where the list is infinite)
>
> try it:
> take -2 [1,2,3,4] -> [3,4]
> drop -2 [1,2,3,4] -> [1,2]
> take -2 [1,2,3,4] ++ drop -2 [1,2,3,4] -> [3,4,1,2]
>
> --brian
>
___________________________________________________________________
S. Alexander Jacobson Shop.Com
1-212-697-0184 voice The Easiest Way To Shop