Tuples

Tuples add some useful properties to the Relevance language. A Tuple is basically a compound type composed of two or more other types. It can be returned directly from an Inspector, like this:

Q: extrema of (1;2;3;4;5)
A: 1, 5
T: 0.127 ms
I: singular ( integer, integer )

This Relevance clause returns a compound object including a time range and an associated boolean TRUE/FALSE. Notice the use of the concatenation operator (&), used here to create a time range (see arithmetic operators, below).

Tuples can also be explicitly generated using the comma (,) keyword. Any mix of types is allowed:

Q: number of processors, "B or not", 8/4, character 66
A: 2, B or not, 2, B
I: ( integer, string, integer, string )

Q: now, "is the time"
A: ( Fri, 22 Sep 2006 12:14:55 -0400 ), is the time
I: ( time, string )

Q: 1, number of processors < 3, "friend"
A: 1, True, friend
I: ( integer, boolean, string )

Note that if an individual Inspector returns a tuple, it will always return the same types in the same order. It’s not possible to have an Inspector return tuples of type <int, string, int> in one case and <int, int, string> in another.

Tuples can also be indexed by using the ‘item’ keyword (indices start at 0). For instance:

Q: item 0 of ("foo", 3, free space of drive of system folder)
A: foo
I: singular string

Q: (item 1 of it; item 2 of it) of ("foo", 3, free space of drive of system folder)
A: 3
A: 18105667584
I: plural integer

Tuples provide a way for a relevance expression to return several related properties. For instance, you could generate a set of filenames and corresponding file sizes for all files that meet a specific criteria with a Relevance statement like this:

Q: (name of it, size of it) of files whose ( size of it > 100000 ) of folder "c:" 
A: hiberfil.sys, 536301568
A: ntldr, 250032
A: pagefile.sys, 805306368
I: plural ( string, integer )