Difference between revisions of "Summary of Programming Constructs"

(Created page with "Category: Analytica User Guide <breadcrumbs> Analytica User Guide > {{PAGENAME}}</breadcrumbs><br /> Please see the table below for a list of Analytica programming constr...")
 
m
Line 11: Line 11:
 
| <code>e1; e2; … ei</code>
 
| <code>e1; e2; … ei</code>
 
| Semicolons join a group of expressions to be evaluated in sequence
 
| Semicolons join a group of expressions to be evaluated in sequence
|
+
|[http://wiki.analytica.com/index.php?title=Begin-End_for_Grouping_Expressions Begin-End for Grouping Expressions]
 
|-
 
|-
 
| <code>BEGIN e1; e2; …</code>
 
| <code>BEGIN e1; e2; …</code>
 
<code>ei END</code>
 
<code>ei END</code>
 
| A group of expressions to be evaluated in sequence
 
| A group of expressions to be evaluated in sequence
|
+
|[http://wiki.analytica.com/index.php?title=Begin-End_for_Grouping_Expressions Begin-End for Grouping Expressions]
 
|-
 
|-
 
| <code>(e1; e2; … ei)</code>
 
| <code>(e1; e2; … ei)</code>
 
| Another way to group expressions
 
| Another way to group expressions
|
+
|[http://wiki.analytica.com/index.php?title=Begin-End_for_Grouping_Expressions Begin-End for Grouping Expressions]
 
|-
 
|-
 
| <code>m .. n</code>
 
| <code>m .. n</code>
 
| Generates a list of successive integers from <code>m</code> to <code>n</code>
 
| Generates a list of successive integers from <code>m</code> to <code>n</code>
|
+
|[http://wiki.analytica.com/index.php?title=Ensuring_Array_Abstraction#Functions_Expecting_Atomic_Parameters Functions Expecting Atomic Parameters]
 
|-
 
|-
 
| <code>Var x := e</code>
 
| <code>Var x := e</code>
 
| Define local variable <code>x</code> and assign initial value <code>e</code>
 
| Define local variable <code>x</code> and assign initial value <code>e</code>
|
+
|[http://wiki.analytica.com/index.php?title=Local_Variables#Defining_a_local_variable Defining a Local Variable]
 
|-
 
|-
 
| <code>Index i := e</code>
 
| <code>Index i := e</code>
 
| Define local index <code>i</code> and assign initial value <code>e</code>
 
| Define local index <code>i</code> and assign initial value <code>e</code>
|
+
|[http://wiki.analytica.com/index.php?title=Local_Indexes Local Indexes]
 
|-
 
|-
 
|<code>x := e</code>
 
|<code>x := e</code>
 
| Assigns value from evaluating <code>e</code> to local variable <code>x</code>.
 
| Assigns value from evaluating <code>e</code> to local variable <code>x</code>.
 
Returns value <code>e</code>.
 
Returns value <code>e</code>.
|
+
|[http://wiki.analytica.com/index.php?title=Local_Variables#Assigning_to_a_local_variable: Assigning to a Local Variable]
 
|-
 
|-
 
| <code>While Test </code><code>Do Body</code>
 
| <code>While Test </code><code>Do Body</code>
 
| While <code>Test</code> is True, evaluate <code>Body</code> and repeat.  
 
| While <code>Test</code> is True, evaluate <code>Body</code> and repeat.  
 
Returns last value of <code>Body</code>.
 
Returns last value of <code>Body</code>.
|
+
|[http://wiki.analytica.com/index.php?title=For_and_While_Loops#While.28Test.29_Do_Body While(Test) Do Body]
 
|-
 
|-
 
| { comments }
 
| { comments }
 
/* comments */
 
/* comments */
 
| Curly brackets { } and /* */ are alternative ways to enclose comments to be ignored by the parser.
 
| Curly brackets { } and /* */ are alternative ways to enclose comments to be ignored by the parser.
|
+
|[http://wiki.analytica.com/index.php?title=Procedural_Programming_Example Procedural Programming Example]
 
|-
 
|-
 
| 'text'
 
| 'text'
 
"text"
 
"text"
 
| You can use single or double quotes to enclose a literal text value, but they must match.
 
| You can use single or double quotes to enclose a literal text value, but they must match.
|
+
|[http://wiki.analytica.com/index.php?title=Text_values Text Values]
 
|-
 
|-
 
| <code>For x := a DO e</code>
 
| <code>For x := a DO e</code>
 
| Assigns to loop variable <code>x</code>, successive atoms from array <code>a</code> and repeats evaluation expression <code>e</code> for each value of <code>x</code>.
 
| Assigns to loop variable <code>x</code>, successive atoms from array <code>a</code> and repeats evaluation expression <code>e</code> for each value of <code>x</code>.
 
Returns an array of values of <code>e</code> with the same indexes as <code>a</code>.
 
Returns an array of values of <code>e</code> with the same indexes as <code>a</code>.
|
+
|[http://wiki.analytica.com/index.php?title=For_and_While_Loops#For_i_:.3D_a_Do_expr For i := a Do expr]
 
|-
 
|-
 
| <code>For x[i, j…] := a DO e</code>
 
| <code>For x[i, j…] := a DO e</code>
 
| Same, but it assigns to x successive sub-arrays of <code>a</code>, each indexed by the indices, <code>[i, j …</code>
 
| Same, but it assigns to x successive sub-arrays of <code>a</code>, each indexed by the indices, <code>[i, j …</code>
|
+
|[http://wiki.analytica.com/index.php?title=For_and_While_Loops#For_i_:.3D_a_Do_expr For i := a Do expr]
 
|-
 
|-
 
| <code>\ e</code>
 
| <code>\ e</code>
 
| Creates a reference to the value of expression <code>e</code>.
 
| Creates a reference to the value of expression <code>e</code>.
|
+
|[http://wiki.analytica.com/index.php?title=References_and_Data_Structures References and Data Structures]
|-
 
| <code>1</code>
 
| <code>VAR result := [1];</code>
 
|
 
 
|-
 
|-
 
| <code>\ [i, j …] e</code>
 
| <code>\ [i, j …] e</code>
 
| Creates an array indexed by any indexes of <code>e</code> other than <code>i, j …</code> of references to sub-arrays of e each indexed by <code>i, j ….</code>
 
| Creates an array indexed by any indexes of <code>e</code> other than <code>i, j …</code> of references to sub-arrays of e each indexed by <code>i, j ….</code>
|
+
|[http://wiki.analytica.com/index.php?title=References_and_Data_Structures References and Data Structures]
 
|-
 
|-
 
| <code># r</code>
 
| <code># r</code>
 
| Returns the value referred to by reference <code>r</code>.
 
| Returns the value referred to by reference <code>r</code>.
|
+
|[http://wiki.analytica.com/index.php?title=References_and_Data_Structures References and Data Structures]
 
|}
 
|}
  

Revision as of 13:21, 20 December 2015


Please see the table below for a list of Analytica programming constructs, their meanings, and links to references with more details, if available.

Construct Meaning: For more, see
e1; e2; … ei Semicolons join a group of expressions to be evaluated in sequence Begin-End for Grouping Expressions
BEGIN e1; e2; …

ei END

A group of expressions to be evaluated in sequence Begin-End for Grouping Expressions
(e1; e2; … ei) Another way to group expressions Begin-End for Grouping Expressions
m .. n Generates a list of successive integers from m to n Functions Expecting Atomic Parameters
Var x := e Define local variable x and assign initial value e Defining a Local Variable
Index i := e Define local index i and assign initial value e Local Indexes
x := e Assigns value from evaluating e to local variable x.

Returns value e.

Assigning to a Local Variable
While Test Do Body While Test is True, evaluate Body and repeat.

Returns last value of Body.

While(Test) Do Body
{ comments }

/* comments */

Curly brackets { } and /* */ are alternative ways to enclose comments to be ignored by the parser. Procedural Programming Example
'text'

"text"

You can use single or double quotes to enclose a literal text value, but they must match. Text Values
For x := a DO e Assigns to loop variable x, successive atoms from array a and repeats evaluation expression e for each value of x.

Returns an array of values of e with the same indexes as a.

For i := a Do expr
For x[i, j…] := a DO e Same, but it assigns to x successive sub-arrays of a, each indexed by the indices, [i, j … For i := a Do expr
\ e Creates a reference to the value of expression e. References and Data Structures
\ [i, j …] e Creates an array indexed by any indexes of e other than i, j … of references to sub-arrays of e each indexed by i, j …. References and Data Structures
# r Returns the value referred to by reference r. References and Data Structures


Comments


You are not allowed to post comments.