The syntax is slightly different if you enter statements on the top level versus when they are inside parentheses or inside functions. On the top level, enter acts the same as if you press return on the command line. Therefore think of programs as just a sequence of lines as if they were entered on the command line. In particular, you do not need to enter the separator at the end of the line (unless it is of course part of several statements inside parentheses). When a statement does not end with a separator on the top level, the result is printed after being executed.
For example,
function f(x)=x^2 f(3)
will print first the result of setting a function (a representation of
the function, in this case (`(x)=(x^2))
)
and then the expected 9. To avoid this, enter a separator
after the function definition.
function f(x)=x^2; f(3)
If you need to put a separator into your function then you have to surround with parenthesis. For example:
function f(x)=( y=1; for j=1 to x do y = y+j; y^2 );
El siguiente código, aunque funcione bien en la función, puede producir un error al introducirlo en el nivel más alto de un programa.
if Algo() then HacerAlgo() else HacerOtraCosa()
El problema es que, después que la Herramienta Matemática Genius ve el caracter de final de línea después de la segunda línea, la aplicación decidirá que ya se a completado la sentencia y la ejecutará. Cuando se termine la ejecución, la Herramienta Matemática Genius continuará con la siguiente línea y producirá un error al leer la sentencia else
. Utilice paréntesis para evitar esto. La Herramienta Matemática Genius no estará satisfecha hasta que todos los paréntesis estén cerrados.
if Algo() then ( HacerAlgo() ) else ( HacerOtraCosa() )