[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Generating a set of structs where each key ranges over a distinct set



Given a structure like this:

    Inventory == [foo |-> 3, bar |-> 2, baz |-> 5] \* How much of an item do we have in store

I'd like to generate the set of structures

    AllPossibleShipments ==
        [foo: 0..3, bar: 0..2, baz: 0..5]

But of course without re-enumerating the items by hand. The most natural thing that came to mind is:

    AllPossibleShipments ==
        [item \in DOMAIN Inventory : 0..Inventory[item]]

That does not work. Any ideas?