The transpose/from/where is used to create a list of elements.
There are two prototypes of this operator according to the from clause used.
Prototype
list <-- transpose query from v1 in list1 [, v2 in list2]+ [ where boolean ] where query and boolean are expressions depending on v1, v2, ...
The value of such a query is a list L built as follows :
let n be the maximum length of the lists list1, list2, ... (n = max(count(list1), count(list2),...)) for i = 1 to n let v1 be the ith element of list1 (v1 = list1[i]) let v2 be the ith element of list2 (v2 = list2[i]) ... if the value of boolean is true then append the value of query to L (L = [ L , query ])
These algorithms can be obviously extended for more than two lists.
Example a clause from with two variables:
$var1 . "/" . $var2 . "\n" from $var1 in [A,B,C] , $var2 in [1,2,3,4] ;
A/1
B/2
C/3
/4
Example:
select $var1 . "/" . $var2 . "\n" from $var1 in ( select $v1 . "/" . $v2 from $v1 in [ A,B,C ] , $v2 in [ 1,2,3,4 ] ) , $var2 in ["a","b","c","d","e","f","g","h"] where count([$var1,$var2]) eq 2 ;A/1/a A/2/b A/3/c A/4/d B/1/e B/2/f B/3/g B/4/h