Combination of a list with permutations of another list

Viewed 171

I have two lists:

object = ['square','circle','triangle']
description = ['red','green']

I want as output a list of dictionaries:

{'square': 'red', 'circle': 'red', 'triangle': 'red'}
{'square': 'red', 'circle': 'red', 'triangle': 'green'}
{'square': 'green', 'circle': 'red', 'triangle': 'green'}

etc.

So the objects don't repeat, but the descriptions may. Each dictionary has as its keys the original list of objects.

I'm not sure of the name of the algorithm I want, so I'm having trouble finding the correct one. (I've looked at permutations of two lists in python, but that's seeking a different result. Permutations of two lists is the same question, but using OCAML.)

1 Answers
Related