Vanguard Software
Forecasting & Planning Solutions
Home Products Solutions Services Customers Partners Company
 
Applying science to business management

contents.gifindex.gifprev1.gifnext1.gif

Referencing List Elements

Once a list has been constructed, you can use the Subscript operator to extract particular elements. This operator has the format list#n where list is the input list and n is the position of the element you want to extract. For example, you can extract the fifth element in a list named Data using the expression Data#5.

You can also use the more traditional JavaScript notation Data[4]. Note that if you use [ ] to reference list elements, the index is zero-based rather than one-based. That is, element index 4 is the fifth element. Therefore, Data#5 is the same as Data[4].

You can extract a sublist from a list by specifying a list of element numbers in n. For example, Data#[2,4,6] will return a list of three elements--the second, fourth, and sixth elements in Data. This expression is equivalent to Data[[1,3,5]].

The Range operator can be used quite effectively in combination with the list element operators as in Data#1..10 (or Data[0..9]). This expression returns a list of the first 10 elements in Data.

If a node named Data contains a matrix rather than a simple list, the expression Data#1 will return the entire first column in the matrix. The expression Data#1#3 will return the third element in the first column of Data. And, Data##3 will return the entire third row. These expressions are equivalent to the expressions Data[0], Data[0][2], and Data[][2] respectively.

  Demand Planning  |  Financial Forecasting
Forecasting Software  |  Strategic Planning Software  |  Decision Tree Software
Decision Support Software  |  Expert System Software  |  Online Surveys

Contact Us  |  Terms of Use  |  Privacy Policy  |  Site Map
Vanguard Software
© 2011 Vanguard Software Corporation
Print this page   Email this page to a friend