Difference between revisions of "Summary of Programming Constructs"

(Making things look pretty :))
Line 6: Line 6:
 
{| 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 «m» to «n»
 
| 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 variable «x» and assign initial value «e»
 
| Define local variable «x» and assign initial value «e»
 
|[[Local_Variables#Defining_a_local_variable|Defining a Local Variable]]
 
|[[Local_Variables#Defining_a_local_variable|Defining a Local Variable]]
 
|-
 
|-
| <code>Index i := e</code>
+
| <code>'''Index''' ''i'' ''':=''' ''e''</code>
 
| Define local index «i» and assign initial value «e»
 
| Define local index «i» and assign initial value «e»
 
|[[Local Indexes]]
 
|[[Local Indexes]]
 
|-
 
|-
|<code>x := e</code>
+
|<code>''x'' ''':=''' ''e''</code>
 
| Assigns value from evaluating «e» to local variable «x».
 
| Assigns value from evaluating «e» to local variable «x».
 
Returns value «e».
 
Returns value «e».
 
|[[Local_Variables#Assigning_to_a_local_variable:|Assigning to a Local Variable]]
 
|[[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 «Test» is <code>True</code>, evaluate «Body» and repeat.  
 
| While «Test» is <code>True</code>, evaluate «Body» and repeat.  
 
Returns last value of «Body».
 
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 «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]]
 
|[[Procedural Programming Example]]
 
|-
 
|-
| 'text'
+
| <code>'' 'text' '''</code>
"text"
+
<code>'''"'''''text'''''"'''</code>
 
| 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]]
 
|[[Text values]]
 
|-
 
|-
| <code>For x := a DO e</code>
+
| <code>'''For''' ''x'' := ''a'' '''Do''' ''e''</code>
 
| Assigns to loop variable «x», successive atoms from array «a» and repeats evaluation expression «e» for each value of «x».
 
| 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».
 
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 Do e</code>
+
| <code>'''For''' ''x[i, j…]'' := ''a'' '''Do''' ''e''</code>
 
| Same, but it assigns to «x» successive sub-arrays of «a», each indexed by the indices, [«i», «j» …]
 
| 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 «e».
 
| 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 «e» other than «i», «j» … of references to sub-arrays of «e» each indexed by «i», «j» ….
 
| 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 «r».
 
| Returns the value referred to by reference «r».
 
|[[References and Data Structures]]
 
|[[References and Data Structures]]

Revision as of 21:12, 7 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;

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

See Also


Comments


You are not allowed to post comments.