Struct arithmetic_eval::fns::Map
source · pub struct Map;
Expand description
Map function that evaluates the provided function on each item of the tuple.
§Type
(using arithmetic-typing
notation)
(['T; N], ('T) -> 'U) -> ['U; N]
§Examples
let program = "
xs = (1, -2, 3, -0.3);
map(xs, |x| if(x > 0, x, 0)) == (1, 0, 3, 0)
";
let program = Untyped::<F32Grammar>::parse_statements(program)?;
let module = ExecutableModule::new("test_map", &program)?;
let mut env = Environment::new();
env.insert_native_fn("if", fns::If).insert_native_fn("map", fns::Map);
assert_eq!(module.with_env(&env)?.run()?, Value::Bool(true));
Trait Implementations§
source§impl<T: 'static + Clone> NativeFn<T> for Map
impl<T: 'static + Clone> NativeFn<T> for Map
source§fn evaluate(
&self,
args: Vec<SpannedValue<T>>,
ctx: &mut CallContext<'_, T>,
) -> EvalResult<T>
fn evaluate( &self, args: Vec<SpannedValue<T>>, ctx: &mut CallContext<'_, T>, ) -> EvalResult<T>
Executes the function on the specified arguments.
impl Copy for Map
Auto Trait Implementations§
impl Freeze for Map
impl RefUnwindSafe for Map
impl Send for Map
impl Sync for Map
impl Unpin for Map
impl UnwindSafe for Map
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)