Sunday, March 3, 2013

Enumerating structure types

Structures associate places with types. If the types of the fields of a structure are enumerated then the entire structure can be enumerated. The following elements are generated by (structure {:x (enum 0 1), :y (enum 0 1)}):
{:x 0, :y 0}, {:x 0, :y 1}, {:x 1, :y 0}, {:x 1, :y 1} 
By using slot places we can enumerate other associative collections as structures. Here is {first (enum 0 1), second (enum 0 1)}
[0 0], [0 1], [1 0], [1 1]
Sets use the contains? place system so here is all subsets of #{false, true} using {(contains? false) bool, (contains? true) bool} where bool is (enum false true):
#{}, #{false}, #{true}, #{false true}
We can also associate places with structures within a structure to enumerate grids. In general, structures are essential because they combine both enumerations and places together into one.

No comments:

Post a Comment