Difference between revisions of "Summary of Programming Constructs"
(Local Variables --> Local Values (terminology change)) |
|||
(8 intermediate revisions by one other user not shown) | |||
Line 4: | Line 4: | ||
Please see the table below for a list of Analytica programming constructs, their meanings, and links to references with more details, if available. | Please see the table below for a list of Analytica programming constructs, their meanings, and links to references with more details, if available. | ||
− | {| class="wikitable" | + | :{| class="wikitable" |
! '''Construct''' | ! '''Construct''' | ||
− | ! '''Meaning | + | ! '''Meaning''' |
! '''For more, see''' | ! '''For more, see''' | ||
|- | |- | ||
− | | <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]] | |[[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]] | |[[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]] | |[[Begin-End for Grouping Expressions]] | ||
|- | |- | ||
− | | <code>m .. n</code> | + | | <code>''m'''''..'''''n''</code> |
− | | Generates a list of successive integers from | + | | Generates a list of successive integers from «m» to «n» |
|[[Ensuring_Array_Abstraction#Functions_Expecting_Atomic_Parameters|Functions Expecting Atomic Parameters]] | |[[Ensuring_Array_Abstraction#Functions_Expecting_Atomic_Parameters|Functions Expecting Atomic Parameters]] | ||
|- | |- | ||
− | | <code>Var x := e</code> | + | | <code>'''Var''' ''x'' ''':=''' ''e''</code> |
− | | Define local | + | | Define local identifier «x» to refer to the value that results from evaluating «e» |
− | |[[ | + | |[[Local_Values#Defining_a_local_value|Defining a Local Value]] |
|- | |- | ||
− | | <code>Index i := e</code> | + | | <code>'''Index''' ''i'' ''':=''' ''e''</code> |
− | | Define local index | + | | Define local index «i» and assign initial value «e» |
|[[Local Indexes]] | |[[Local Indexes]] | ||
|- | |- | ||
− | |<code>x := e</code> | + | |<code>''x'' ''':=''' ''e''</code> |
− | | Assigns | + | | Assigns the result from evaluating «e» to local value «x». |
− | Returns value | + | Returns value «e». |
− | |[[ | + | |[[Local_Values#Assigning_to_a_local_value:|Assigning to a Local Value]] |
|- | |- | ||
− | | <code>While Test </code><code>Do Body</code> | + | | <code>'''While''' ''Test'' </code><code>'''Do''' ''Body''</code> |
− | | While <code> | + | | While «Test» is <code>True</code>, evaluate «Body» and repeat. |
− | Returns last value of | + | Returns last value of «Body». |
|[[For_and_While_Loops#While.28Test.29_Do_Body|While(Test) Do Body]] | |[[For_and_While_Loops#While.28Test.29_Do_Body|While(Test) Do Body]] | ||
|- | |- | ||
− | | { comments } | + | | <code>'''{''' ''comments'' '''}'''</code> |
− | /* comments */ | + | <code>'''/*''' ''comments'' '''*/'''</code> |
− | | Curly brackets { } and /* */ are alternative ways to enclose | + | | Curly brackets { } and /* */ are alternative ways to enclose «comments» to be ignored by the parser. |
|[[Procedural Programming Example]] | |[[Procedural Programming Example]] | ||
|- | |- | ||
− | | 'text' | + | | <code>'' 'text' '''</code> |
− | "text" | + | <code>'''"'''''text'''''"'''</code> |
− | | You can use single or double quotes to enclose a literal | + | | You can use single or double quotes to enclose a literal «text» value, but they must match. |
|[[Text values]] | |[[Text values]] | ||
|- | |- | ||
− | | <code>For x := a | + | | <code>'''For''' ''x'' := ''a'' '''Do''' ''e''</code> |
− | | Assigns to loop variable | + | | 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 | + | Returns an array of values of «e» with the same indexes as «a». |
|[[For_and_While_Loops#For_i_:.3D_a_Do_expr|For i := a Do expr]] | |[[For_and_While_Loops#For_i_:.3D_a_Do_expr|For i := a Do expr]] | ||
|- | |- | ||
− | | <code>For x[i, j…] := a | + | | <code>'''For''' ''x[i, j…]'' := ''a'' '''Do''' ''e''</code> |
− | | Same, but it assigns to | + | | Same, but it assigns to «x» successive sub-arrays of «a», each indexed by the indices, [«i», «j» …] |
|[[For_and_While_Loops#For_i_:.3D_a_Do_expr|For i := a Do expr]] | |[[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 | + | | Creates a reference to the value of expression «e». |
|[[References and Data Structures]] | |[[References and Data Structures]] | ||
|- | |- | ||
− | | <code>\ [i, j …] e</code> | + | | <code>'''\'''''[i, j …]e''</code> |
− | | Creates an array indexed by any indexes of | + | | 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]] | |[[References and Data Structures]] | ||
|- | |- | ||
− | | <code># r</code> | + | | <code>'''#'''''r''</code> |
− | | Returns the value referred to by reference | + | | Returns the value referred to by reference «r». |
|[[References and Data Structures]] | |[[References and Data Structures]] | ||
|} | |} | ||
==See Also== | ==See Also== | ||
+ | * [[Expression Assist]] | ||
+ | * [[Expression Syntax]] | ||
+ | * [[Using References]] | ||
+ | * [[Function calls and parameters]] | ||
+ | * [[User-Defined Functions]] | ||
+ | * [[Evaluate]] | ||
+ | |||
<footer>Procedural Programming Example / {{PAGENAME}} / Begin-End for Grouping Expressions</footer> | <footer>Procedural Programming Example / {{PAGENAME}} / Begin-End for Grouping Expressions</footer> |
Latest revision as of 00:17, 5 January 2017
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 identifier «x» to refer to the value that results from evaluating «e» Defining a Local Value Index i := e
Define local index «i» and assign initial value «e» Local Indexes x := e
Assigns the result from evaluating «e» to local value «x». Returns value «e».
Assigning to a Local Value 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
See Also
- Expression Assist
- Expression Syntax
- Using References
- Function calls and parameters
- User-Defined Functions
- Evaluate
Comments
Enable comment auto-refresher