Skip to content

Instantly share code, notes, and snippets.

@bgnori
Created May 2, 2012 05:14
Show Gist options
  • Save bgnori/2573990 to your computer and use it in GitHub Desktop.
Save bgnori/2573990 to your computer and use it in GitHub Desktop.
import sys
def _each(f, xs):
x = xs[0]
f(x)
if xs[1:]:
_each(f, xs[1:])
def _shortest(i, *rs):
def f(r):
try:
x = r[i]
except IndexError:
print r
sys.exit(0)
_each(f, rs)
_shortest(i+1, *rs)
def shortest_r(*rs):
_shortest(0, *rs)
print shortest_r([1, 2], [3, 4, 5], [6, 7])
@bgnori
Copy link
Author

bgnori commented May 2, 2012

pythonで再代入・破壊変更禁止(for文禁止)は苦しいね。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment