Skip to main content

Field Projection



Projection of tuple.


Exp < Field₁, Field₂ ... >


Exp should evaluate to a tuple or relation, and Fieldᵢ should be a field name or an integer constant that refers to elements in the order in which they occur in the original value (counting from 0).


Suppose we have a relation with traffic information that records the name of the day, the day number, and the length of the traffic jams at that day.

rascal>rel[str day, int daynum, int length] Traffic = 
>>>>>>>{<"mon", 1, 100>, <"tue", 2, 150>, <"wed", 3, 125>,
>>>>>>> <"thur", 4, 110>, <"fri", 5, 90>};
rel[str day,int daynum,int length]: {
rel[int length,int daynum]: {
rel[int length,str day]: {

Field projection thus selects parts from a larger value that has a fixed number of parts. The selection is based on position and not on value and can be used to completely reorder or remove the parts of a larger value.