Hi. I’m interested in learning more about creating Iterables to save space. In particular, right now I want to create an Iterable that runs through the rows of a truth table. The following code generates an array that (almost) contains what I want, however an array will take up exponental space, when what I actually want is to iterate over the rows implemented as Dict
s:
vars = Set(["a","b","c"])
map(t->Dict(zip(vars,t)),Base.product([false:true for k in vars]...))
The idea is that each Dict
-row represents a unique assignment of true/false values to the variable names contained in vars. I’ve only just discovered Base.product()
, and it serves its purpose here of generating the assignments, however it only generates them as Tuples, so I still have to map them onto Dict
s, which then essentially collect
s the rows, rather than leaving them as an abstract Iterable. Ideally, I’d also like to specify the order of iteration in the classic binary counting sequence. Can anyone help?
Thanks!