Skip to content

Instantly share code, notes, and snippets.

@moiseev
Created May 31, 2013 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save moiseev/5682923 to your computer and use it in GitHub Desktop.
Save moiseev/5682923 to your computer and use it in GitHub Desktop.
def append(xs, yss):
return [[x] + ys for x in xs for ys in yss]
def make_lists(*xss):
if len(xss) == 1:
return [[x] for x in xss[0]]
h, t = xss[0], xss[1:]
return append(h, make_lists(*t))
def main():
xs = [0, 1, 2]
ys = [4, 5]
zs = [10, 20]
print make_lists(xs, ys)
print make_lists(xs, ys, zs)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment