[Haskell-beginners] splitAt and negative values
Stayvoid
stayvoid at gmail.com
Thu Sep 6 19:24:13 CEST 2012
Hello,
Could you explain this behaviour?
> splitAt (-1) "Foobar"
("","Foobar")
> splitAt (-100) "Foobar"
("","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'
Thanks
More information about the Beginners
mailing list