-
-
Save gabraganca/5682956 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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