Function definition: Difference between revisions

Content deleted Content added
Alt (talk | contribs)
No edit summary
Line 538:
ok
</pre>
 
=={{header|ERRE}}==
A statement function in ERRE is a '''single line''' function definition as in Fortran 77 or BASIC. These are useful in defining functions that can be expressed with a single formula. A statement function should appear in declaration part of the program. The format is simple - just type
FUNCTION f(x,y,z,…)
f=formula
END FUNCTION
 
The main features of function statement are:
1) You can use relational operators, so it's possible to "compact" an IF THEN ELSE statement but not loop statements: you must use a procedure for this.
2) Functions can have their own identifier (integer, string, real,double)
3) At least one parameter must be present, although it couldn't be used
4) Functions always return '''one''' value
5) ERRE for C-64 admits only real with one parameter functions.
 
FUNCTION DIAGONAL(X,Y,Z)
DIAGONAL=SQR(X*X+Y*Y+Z*Z)
END FUNCTION
 
=={{header|Euphoria}}==