[Haskell-beginners] splitAt and negative values

Brandon Allbery allbery.b at gmail.com
Fri Sep 7 04:06:57 CEST 2012

On Thu, Sep 6, 2012 at 1:24 PM, Stayvoid <stayvoid at gmail.com> wrote:

> > splitAt (-1) "Foobar"
> ("","Foobar")

As others have mentioned, this falls out of the way Haskell implements
lists; Perl and Python "lists" are more like Vector, and the end of the
list is easier to locate and operate on.

It's also worth noting that experience with Perl is that the negative index
thing is prone to error (a fencepost error reverses the function's
behavior) and Perl 6 has ditched it in favor of a more explicit syntax for
the negative index mechanism.

brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120906/46056b1e/attachment.htm>

More information about the Beginners mailing list