Created
August 3, 2017 14:51
-
-
Save JPFrancoia/b6501ab34a0917384ad24d8018b1ff13 to your computer and use it in GitHub Desktop.
Frange: range function with floats increment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def frange(start, end=None, inc=None): | |
"A range function, that does accept float increments..." | |
if end == None: | |
end = start + 0.0 | |
start = 0.0 | |
if inc == None: | |
inc = 1.0 | |
L = [] | |
while 1: | |
next = start + len(L) * inc | |
if inc > 0 and next >= end: | |
break | |
elif inc < 0 and next <= end: | |
break | |
L.append(next) | |
return L |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment