FunctionSet Statement |
|
FunctionSet Statement SyntaxThe Fractal Science Kit fractal generator functionSet statement is 1 of the statements used in the properties section of the program instructions to define the program's Properties. A function proxy is an option that represents a function. In your code, you invoke a function proxy just like you invoke a function except that the name of the function is the proxy name. The compiler replaces the function proxy with the actual function at compile time. A functionSet statement is used to create a list of functions that can be associated with a function proxy. The syntax of the functionSet statement is: functionSet <FunctionSetName> { The <FunctionSetName> must be a valid identifier. Each of the <Function> items must be an existing function (including inline functions). All the functions in the list must exist and accept the same number and type of arguments used to invoke the proxy. Otherwise, an error is generated when you try to compile the program. You may name multiple functions on the same line separated by 1 or more spaces if desired. Functions defined in the macros section of the program instructions cannot be used in a functionSet statement since the macros section is compiled after the properties section to allow the macros to reference the program properties. Also, functions associated with a function proxy are not validated until they are actually used, so any undefined functions included in the list or any functions with the incorrect number of arguments, are not flagged as such until the user sets the function proxy to the invalid function and tries to compile/run the program. Example: functionSet HyperbolicFunctions { These statements define a function proxy named F based on the set of functions named in HyperbolicFunctions as shown below: In your code you can call F using: result = F(z) This sets result to the value F(z) where F is the function selected by the user for the associated option. Several functionSet statements are defined in the built-in macros including:
By far, the most commonly used functionSet is ComplexFunctions. ComplexFunctions is used in many of the built-in programs where a function proxy is required. See Complex Functions for details. The following is an example that uses ComplexFunctions to define a function proxy F: properties: This results in the function proxy F as shown below:
|
Copyright © 2004-2019 Ross Hilbert |