(sorry, can't remember the original author)
> | 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 ex
| 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
> Simon Peyton-Jones <[EMAIL PROTECTED]> wrote:
>
> > (A) Make them defined for any n. If n < 0, do something reasonable:
> > take: give empty list
> > drop: give whole list
> >
> > (B) Make them defined for n > length xs, but fail for n < 0.
I vote for (B).
'Qrczak' Kowal
Mon, 24 Jan 2000 07:49:30 -0800, Simon Peyton-Jones <[EMAIL PROTECTED]> pisze:
> (A) Make them defined for any n. If n < 0, do something reasonable:
> take: give empty list
> drop: give whole list
>
> (B) Make them defined for n > length xs, but fail for n < 0.
I vote for (
[EMAIL PROTECTED]>
Sent: Monday, 24 January 2000 02:39 pm
Subject: Re: fixing typos in Haskell-98
> Brian Boutel wrote:
>
>
> > take -2 [1,2,3,4] ++ drop -2 [1,2,3,4] -> [3,4,1,2]
>
> But [1,2,3,4] is NOT the same as [3,4,1,2]. So the equality doesn't hold.
>
>
Brian Boutel wrote:
> take -2 [1,2,3,4] ++ drop -2 [1,2,3,4] -> [3,4,1,2]
But [1,2,3,4] is NOT the same as [3,4,1,2]. So the equality doesn't hold.
Personally, for reasons I'm not sure I can articulate, I've always strongly
disliked the notion that negative arguments should produce "backwards"
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
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 +
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
If the list is an infinite list, the behavior is equivalent to B.
If
> Take and drop
> [..]
> I can see three alternatives:
>
> (A) Make them defined for any n. If n < 0, do something reasonable:
> take: give empty list
> drop: give whole list
>
> (B) Make them defined for n > length xs, but fail for n < 0.
>
> (C) Status quo
>
> PROPOSAL: Use al
> > Take and drop
> > [..]
> > I can see three alternatives:
> >
> > (A) Make them defined for any n. If n < 0, do something reasonable:
> > take: give empty list
> > drop: give whole list
> >
> > (B) Make them defined for n > length xs, but fail for n < 0.
> >
> > (C) Status quo
> >
11 matches
Mail list logo