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 );
Ο παρακάτω κώδικας θα παράξει ένα σφάλμα όταν εισαχθεί στο ανώτατο επίπεδο ενός προγράμματος, ενώ θα δουλέψει θαυμάσια σε μια συνάρτηση.
if Something() then DoSomething() else DoSomethingElse()
Το πρόβλημα είναι ότι μετά το Εργαλείο μαθηματικών Genius βλέπει το τέλος της γραμμής μετά τη δεύτερη γραμμή, θα αποφασίσει ότι έχουμε ολόκληρη τη δήλωση και θα την εκτελέσει. Μετά την εκτέλεση, το Εργαλείο μαθηματικών Genius θα συνεχίσει με την επόμενη γραμμή, θα δει το else
και θα παράξει ένα σφάλμα ανάλυσης. Για να το διορθώσετε, χρησιμοποιήστε παρενθέσεις. Το Εργαλείο μαθηματικών Genius δεν θα ικανοποιηθεί μέχρι να βρει ότι όλες οι παρενθέσεις έχουν κλείσει.
if Something() then ( DoSomething() ) else ( DoSomethingElse() )