Skip to content

Instantly share code, notes, and snippets.

@mhrivnak
Created April 3, 2013 16:36
Show Gist options
  • Save mhrivnak/5302891 to your computer and use it in GitHub Desktop.
Save mhrivnak/5302891 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
version_elements = [
'1',
'12',
'1a',
'12abc3d4ef',
]
def foo(x, y):
if isint(x[-1]) != isint(y):
y = '.' + y
return x + y
def isint(n):
try:
int(n)
return True
except ValueError:
return False
for x in version_elements:
print reduce(foo, x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment