macro_rules! create_func {
( $func:ident, $args:expr ) => { ... };
}Expand description
Creates a Function object from an actual function and an Arguments object.
See Function::new for additional information.
The generated Function has the same name as the provided function. The provided function
needs &Vec<Box<Expression>>, a &Context and a u32 (for depth controls) as parameters and
returns an EvalResult<Values>. You can easily declare one using the decl_func! macro.
ยงExamples
use num_parser::{*, function::*};
// Declare the function
decl_func!(
// Function name
hypotenuse,
// Function type
FunctionType::Std,
// Predicate
|v: Value| {
// ...
},
// Expect a vector as input, as we need multiple parameters.
ValueType::VectorType
);
let hyp_func = create_func!(hypotenuse, Arguments::Const(2));
builtin::add_built_in_function(hyp_func);