Show HN: Intspan, because 1,3-7 is better than [1,3,4,5,6,7]
pypi.python.org
pypi.python.org
> s = c(1:3, 14, 29, 92:97)
> s
[1] 1 2 3 14 29 92 93 94 95 96 97
I think I prefer the 1:3 syntax versus 1-3, especially when dealing with negative numbers.In R:
> -6:-3
[1] -6 -5 -4 -3
In intspan: >>> s = intspan('-6--3')
>>> list(s)
[-6, -5, -4, -3]
So the syntax is a little funky.Another thing is that R will allow you to go from big to small:
> 2:-3
[1] 2 1 0 -1 -2 -3
Whereas intspan doesn't seem to support this at all: >>> s = intspan('2--3')
>>> list(s)
[]
Very cool though!I like that "generalized range" operator from R. And it's a nice closed interval, not the half-open annoyance of Python's range() function.