Difference between revisions of "Summary of Programming Constructs"
Jhernandez3 (talk | contribs) 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 | ||
− | |[ | + | |[[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 | ||
− | |[ | + | |[[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 | ||
− | |[ | + | |[[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> | ||
− | |[ | + | |[[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> | ||
− | |[ | + | |[[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> | ||
− | |[ | + | |[[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>. | ||
− | |[ | + | |[[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>. | ||
− | |[ | + | |[[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. | ||
− | |[ | + | |[[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. | ||
− | |[ | + | |[[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>. | ||
− | |[ | + | |[[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> | ||
− | |[ | + | |[[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>. | ||
− | |[ | + | |[[References and Data Structures]] |
|- | |- | ||
| <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> | ||
− | |[ | + | |[[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>. | ||
− | |[ | + | |[[References and Data Structures]] |
|} | |} | ||
− | + | ==See Also== | |
<footer>Procedural Programming Example / {{PAGENAME}} / Begin-End for Grouping Expressions</footer> | <footer>Procedural Programming Example / {{PAGENAME}} / Begin-End for Grouping Expressions</footer> |
Revision as of 03:27, 5 January 2016
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; …
|
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 |
Assigning to a Local Variable |
While Test Do Body
|
While Test is True, evaluate Body and repeat.
Returns last value of |
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 |
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 |
See Also
Comments
Enable comment auto-refresher