Given a record such as:
This record can be used with the table:
This table is a way of organizing information per given record type. In general, the table is a useful construct which enables many common operations found in data structures. The above record would create a table like
A table in and of itself requires a toolkit to handle it, and we introduce a variant of SQL in the form a language integrated query (LINQ). It is a variant in many ways, and we will introduce the mechanics.
Lists of records can be filtered, ordered, sequenced, and limited via language integrated query (LINQ).
iterate keyword will convert the table<Rec> into a list<Rec>.
Now, by itself, it will list the records in their canonical ordering (by id). It is important to note that the list is lazily constructed up until the time that it is materialized by a consumer, and this enables some query optimizations to happen on the fly.
We can suffix a LINQ expression with where to filter items.
Yes, we can make things faster by indexing our tables. The
index keyword within a record will indicate how tables should index the record.
This will accelerate the performance of
where expressions when expressions like
age == 42 are detected via analysis.
The canonical ordering by id is not great for card games, so we can randomize the order of the list. Now, this will materialize the list.
Since the canonical ordering by id is the insertion/creation ordering, order allows you to reorder any list;
A novel aspect of a reactive list is bulk field assignment, and this allows us to do some nice things. Take the following definition of a Card table representing a deck of cards.
We can shuffle the deck using
shuffle and bulk assignment.
This assignment of ordering will memorize the results from shuffling. With a single statement, we can deal cards by assigning ownership.
This ability makes it simple to update a single field, but it also applies to method invocation as well.