Collections and Lists

Datamixer gets its values by iterating over collections of data. A collection is an unordered group of elements. A list is an ordered collection. Examples of lists are the integers, or the names of months.

Some Datamixer collections have concrete values (e.g. a set of strings read from a file), and some synthesize their values. Primitive datatypes (such as numbers) are usually modeled by synthetic collections. This is because it saves space to generate them, rather than store instances of them in a collection. The standard datatypes (boolean, char, short, int, float, double, string, date, etc.) are supported.

The range of a synthetic collection is defined by its first and last values (bounds), and optionally an increment. Bounds are placed between parens or square brackets: a parenthesis indicates an open bound, and a square bracket indicates a closed bound. The increment, if there is one, follows the closing parenthesis or bracket.

For example, these ranges generate these values:

  • [first,last]step generates values that start with first and end with last. Each next value increments by step. For example, [10,20]3 generates 10,13,16,19.
  • [first]step generates values that start with first and have no upper bound. Each next value increments by step. For example, [10]2 generates 10,12,14,...
  • [first] is the same as [first]step with step = 1.
  • [] is the same as [first], with first = 0.

The notation for range is:

Range       ::= OpenBound First (',' Last)? CloseBound Increment?
OpenBound   ::= '(' | '['
CloseBound  ::= ')' | ']'
First       ::= Value
Last        ::= Value
Increment   ::= Value
Value       ::= datatype instance

For example:

XML
Generates
<ints>Integers, starting at 0, incrementing by 1, with no upper bound.
<ints range="[22]">Integers, starting at 22, incrementing by 1, with no upper bound.
<ints range="[22]-1">Integers, starting at 22, decrementing by 1, with no lower bound.
<ints range="[0,10)">10 integers, numbered 0-9.
<ints range="[0,10]2">6 integers: 0, 2, 4, 6, 8, 10.
<ints range="[10,-1]-5">3 integers: 10, 5, 0.