Function definition: Difference between revisions

Applesoft BASIC
(Applesoft BASIC)
Line 57:
return a * b
end</lang>
 
=={{header|Applesoft BASIC}}==
Applesoft BASIC functions are unary meaning they only take one argument. As the task asks for a multiply function which takes two arguments this poses a problem. To get around this, the multiply function MU takes one argument with the decimal point delimiting two "pseudo" arguments. The pseudo arguments to the function are limited to integers.
 
<lang basic>10 DEF FN B(AB) = INT ((AB - INT (AB)) * (10 ^ ( LEN ( STR$ (AB)) - LEN ( STR$ ( INT (AB))) - 1)) + .5)
20 DEF FN MU(AB) = INT (AB) * FN B(AB)
30 PRINT FN MU(611.78) : REM 611 TIMES 78</lang>
 
The result is limited to a maximum of nine digits.
 
<lang basic>47658</lang>
 
=={{header|Argile}}==
413

edits