===== HyperFun: Statements ===== There are four types of the statements each ending with ';': * [[hf_statements#assignment_statement_for_a_variable|Assignment statement for a variable]] * [[hf_statements#assignment_statement_for_an_array|Assignment statement for an array]] * [[hf_statements#conditional_statement|Conditional statement]] * [[hf_statements#iterative_statement|Iterative statement]] ==== Assignment statement for a variable. ==== Its general form is: // '=' ';'// Here //// is a name of any local variable (including name of array's element) or a name of a coordinate variable. Examples: ''i = 1;\\ i = i + 1;\\ x1 = x[1] + a[1];\\ Metric[2] = b + aa[I]* exp(-sqrt(xx1^2 + x[2]^3);\\ StrangeBody = Head | (Hand[1] & Leg[2]);\\ sphere1 = Sphere(x,a);'' ==== Assignment statement for an array. ==== This statement allows to assign values to all elements of array. Its general form is: // '=' '[' , ..., ']' ';'// Example: ''pz = [100., -20, 2, 0., 0., -3, 0., 0., 1E-10];'' ==== Conditional statement ==== It is a traditional 'if-then-else' statement having two forms: * //'if' 'then' 'endif' ';'// * //'if' 'then' 'else' 'endif' ';'// Example: ''if (x[4]= 0) then metamorph = CSGobject;\\ else if (x[4] = 1) then metamorph = blobbyobject;\\ endif;\\ endif;'' ==== Iterative statement ==== The iterative statement allows to define repeating loops. Its general form is: //'while' '(' ')' 'loop' 'endloop' ';'// Example: ''i=1;\\ while (i<10) loop\\ xt[i] = x[1] - x0[i];\\ i = i+1; \\ endloop;''