[Haskell-beginners] splitAt and negative values

Stayvoid stayvoid at gmail.com
Thu Sep 6 19:24:13 CEST 2012


Could you explain this behaviour?

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

I don't understand why splitAt (-1) "Foobar" doesn't output this:
("r", "Fooba")
or this:
("", "Fooba")

How does it work?

Python's list slicing looks similar, but results for negative values differ:
>>> a = "Foobar"
>>> a[:-1]
>>> 'Fooba'


More information about the Beginners mailing list