| 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..
I believe the names "take" and "drop" originally came from
APL. APL interprets negative arguments for these operators
to mean "from the end" (in the sense of the first definitions
you gave). There are two good reasons _not_ to follow APL's
lead here:
1. APL values are arrays, which have a directional
symmetry that cons lists do not.
2. APL was essentially forced into using signs of the
left argument to specify ends of the right argument
because it deals with multidimensional arrays: One
needs to specify which of the 2^n corners of an
n-dimensional hypercube to operate on. No such
consideration applies to lists.
Cheers,
--Joe
Joseph H. Fasel, Ph.D. email: [EMAIL PROTECTED]
Technology Modeling and Analysis phone: +1 505 667 7158
University of California fax: +1 505 667 2960
Los Alamos National Laboratory postal: TSA-7 MS F609
Los Alamos, NM 87545