0

What would you call the function that takes a list of n lists of values, and returns a list of all the unique lists of length n where the ith element is chosen from the ith input list?

For example:

[[a,b], [c], [d, e]]
=>  [[a,c,d], [a,c,e], [b,c,d], [b,c,e]]

At first I called it permute, but then I realized that would be the function that takes a single list and return all possible orderings, e.g. [1,2,3] => [[1,2,3], [1,3,2], [2,1,3], ... or something similar.

  • I would call it "combinations". – juhist Mar 17 '17 at 18:28
  • Huh. I just noticed this question was closed. That's dumb. I mean, are people just gonna close every naming question then? I don't see how other questions under this tag could be any less opinion-based. – Michael Hewson Feb 12 '18 at 21:20
3

That's calculating a Cartesian product. In particular, it's an n-fold Cartesian product, given that there are n lists to combine.

  • The Cartesian product :). – Alexey Mar 17 '17 at 18:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.