How can I use ramda's sequence
to traverse a dictionary?
Given the following dictionary
cars = {color: ['yellow', 'red'], year: [2017], model: ['coup', 'sedan']}
I'd like to produce the traversed result
all_cars = [
{color: 'yellow', year: 2017, model: 'coup'},
{color: 'yellow', year: 2017, model: 'sedan'},
{color: 'red', year: 2017, model: 'coup'},
{color: 'red', year: 2017, model: 'sedan'}
]
Using R.sequence
results in a list of an empty list
R.sequence(R.of, cars)
[[]]
If I traverse a list instead of a dictionary it produces the correct cartesian product, but the results are (of course) lists instead of dictionaries.
R.sequence(R.of, [['yellow', 'red'], [2017], ['coup', 'sedan']])
[["yellow", 2017, "coup"], ["yellow", 2017, "sedan"], ["red", 2017, "coup"], ["red", 2017, "sedan"]]