Lemur Monitors Jazzmutant Lemur User Manual

Page of 122
Working with your Lemur 
62 
3.4.7. Vector Datacrunching 
vector
 (also known as an array or list), is a variable that holds more 
than  one  element  (number).  The  Lemur  expression  syntax  allows  operations  on 
vectors and individual access to their elements. You can access the data in certain 
Lemur  Objects  (MultiSlider,  MultiBall,  Pads,  Switches)  as  vectors.  Typically  each 
sub  object
” is an element  of a vector. For example, the x coordinates of the 
balls in a Multiball object are accessed as  
• 
myball.x[0] 
• 
myball.x[1] 
• 
etc. 
Let’s look at some of the operations you can perform on vectors. Assume 
we  have  a 
MultiSlider
  object  called 
moo
  and  a 
MultiBall
  object  called 
bar
. Below we have listed some expressions involving vectors and the results they 
would  produce.  Assume 
moo.x  contains  {0.2  0.3  0.6}
  and 
bar.x 
contains {0.25 0.5} 
• 
moo.x * 3 
Multiply all elements of moo.x by 3, returns {0.6 0.9 1.8} 
• 
moo.x + 2 
Add 2 to all elements of moo.x, returns {2.2 2.3 2.6} 
• 
moo.x>0.5 
Return a vector consisting of 1 or 0 depending on whether moo.x is 
greater than 0.5, returns {0. 0. 1.} 
• 
moo.x + bar.x  Add all elements of two vectors. The size of the result is the smaller 
of the two input vectors. Returns {0.45 0.8} 
• 
moo.x[0] 
The first (index 0) element of moo.x, returns 0.2 
• 
bar.x[1] The second element of bar.x, return 0.5 
• 
moo.x[0.5] 
Interpolated value between bar.x[0] and bar.x[1], returns 0.3 
• 
{moo.x, bar.x}  Concatenates moo.x and bar.x, returns {0.2 0.3 0.6 0.25 0.5} 
• 
{moo.x[0],bar.x[1.5]} 
Creates a new vector consisting of the first element of moo.x 
and the average of the second and third elements of bar.x, returns {0.2 0.625} 
Please  have  a  look  at  the 
Parser
 
Reference
  for  a  complete 
overview of the possibilities.