module Vectors { 
 
  // VECTOR BASICS 
   
  // Vectors are strutural types with zero or more elements of the same type 
  // Each vector element apears directly within the vector structure, instead 
  // of being separately allocated.  the size of a vector is always known at  
  // compile time.  vectors are written #() with values between  
  // ( and ), separated by commas.  vectors are immutable by default. 
 
  fn test1() { 
    let x1 = #(1, 2, 3);              // vector of 3 integers 
    let x2 = #(1.0, 2.0, 3.0, 4.0);   // vector of 4 doubles 
 
    // use type#count when specifying the type of a vector.  the number 
    // of elements is part of the type, so two vectors only have the same type if  
    // they have the same element type and the same number of elements. 
    let x3 : int#3 = #(1, 2, 3);    // vector of three integers 
 
    // vectors support math operations when the two vectors have the same element 
    // type and the number number of elements.  the math operations are applied 
    // to all the values in the vector, producing a new vector with the result. 
    // this is supported natively on some processor architectures. 
 
    let x4 = #(1, 1, 1); 
    let x5 = #(1, 1, 1); 
    let x6 = x4 + x5;     // #(2, 2, 2) 
 
    // to access a field of a vector v, use v.n where n is the 
    // zero-based index of the field.  alternatively, vectors can be  
    // accessed using v[n]. 
    let x7 = x1.1;    // 2 
    let x8 = x1[0];   // 1 
 
    // use # to get the number of elements in a vector 
    let x9 = x1#;     // 3 
 
    // vectors support iteration 
    for (x in #(1, 2, 3)) { 
      print(x);   // prints 1, 2, 3 
    } 
  } 
}