Chapter 6: Programming
62
6.10 Implicit scaling If a numeric literal is in front of certain types of expressions, then the two are multiplied: int x=2; real y=2.0; real cm=72/2.540005; write(3x); write(2.5x); write(3y); write(-1.602e-19 y); write(0.5(x,y)); write(2x^2); write(3x+2y); write(3(x+2y)); write(3sin(x)); write(3(sin(x))^2); write(10cm); This produces the output 6 5 6 -3.204e-19 (1,1) 8 10 18 2.72789228047704 2.48046543129542 283.464008929116
6.11 Functions Asymptote functions are treated as variables with a signature (non-function variables have null signatures). Variables with the same name are allowed, so long as they have distinct signatures. Functions arguments are passed by value. To pass an argument by reference, simply enclose it in a structure (see Section 6.8 [Structures], page 56). Here are some significant features of Asymptote functions: 1. Variables with signatures (functions) and without signatures (nonfunction variables) are distinct: int x, x(); x=5; x=new int() {return 17;}; x=x(); // calls x() and puts the result, 17, in the scalar x 2. Traditional function definitions are allowed: