cartesian
cartesian copied to clipboard
Similarity with list comprehensions
I see this library as a way of expressing list comprehensions in javascript. Your example can be written this way using list comprehensions (using syntax from python and haskell and ecmascript):
config = [
{box, compiler, test, cmdline}
for box in [box1, box2, box3, box4],
for compiler in [gcc, clang, msvc],
for test in [frobnicate, loadtest, end2end],
let cmdline = compiler.binary + ' ' + test.sources + ' -o ' + test.binary,
!(test.binary == 'loadtest' && box.ram < 8)
]
Maybe it could be pedagogical to point this out in the readme.
Good point. It can be implemented using list comprehensions. However, I think that diving into implementation details would divert the attention from the concept I was trying to express.