Range

The Range syntax can be used to get or modify a certain range in vector. A range is an object itself that is simply a pair of ints, and it can be constructed either by:

<int> to <int>, like "2 to 3", which are the starting and ending index (inclusive).

<int> size <int>, like "2 size 2", which are starting index and length.

Example:
main
  
  int[] vec                 // Creates a new vector named "vec"
                            // that can contain ints
  vec &= 1
  vec &= 2
  vec &= 3
  vec &= 4
  vec &= 5                  // vec has now value 1, 2, 3, 4, 5
  
  print vec[0]              // Prints 1
  
  vec2 = vec[0 to 1]        // Copies values from vec's index 0 to 1 to vec2,
                            // so vec2 has now values 1, 2
  
  vec[2 to 3] = vec2        // Replaces items at indices 2 and 3 in vec
                            // with contents from vec2.
                            // vec has now value 1, 2, 1, 2, 5
  
  vec[2 size 0] = vec2      // Insert contents of vec2 before index 2 in vec.
                            // vec has now values 1, 2, 1, 2, 1, 2, 5
  
  print vec.get size        // Prints number of elements in vec, now 7

API Documentation: Class Range