Toppnivåsyntax

Syntaxen skiljer sig något beroende på om du matar in satser på toppnivån gentemot då de används inom parenteser eller i funktioner. På toppnivån uppför sig retur just som om du tryckte retur på kommandoraden. Tänk därför på program som bara en följd av rader som matats in på kommandoraden. I synnerhet behöver du inte ange avskiljaren i slutet på raden (om den inte är del av flera satser inom parenteser). Då en sats inte avslutas med en avskiljare på toppnivån skrivs resultatet ut efter körning.

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
);

The following code will produce an error when entered on the top level of a program, while it will work just fine in a function.

if Something() then
  DoSomething()
else
  DoSomethingElse()

The problem is that after Genius Mathematics Tool sees the end of line after the second line, it will decide that we have whole statement and it will execute it. After the execution is done, Genius Mathematics Tool will go on to the next line, it will see else, and it will produce a parsing error. To fix this, use parentheses. Genius Mathematics Tool will not be satisfied until it has found that all parentheses are closed.

if Something() then (
  DoSomething()
) else (
  DoSomethingElse()
)