pub struct LambdaFn;Trait Implementations§
Source§impl Function for LambdaFn
Creates an anonymous callable that can be invoked with spreadsheet arguments.
impl Function for LambdaFn
Creates an anonymous callable that can be invoked with spreadsheet arguments.
LAMBDA captures its defining local scope and returns a reusable function value.
§Remarks
- All arguments except the last are parameter names; the last argument is the body expression.
- Parameter names must be unique (case-insensitive), or
#VALUE!is returned. - Invocation arity must exactly match the declared parameter count.
- Returning an uninvoked lambda as a final cell value yields a
#CALC!in evaluation.
§Examples
title: "Inline lambda invocation"
formula: "=LAMBDA(x,x+1)(41)"
expected: 42title: "Lambda captures outer LET bindings"
formula: "=LET(k,10,addk,LAMBDA(n,n+k),addk(5))"
expected: 15title: "Duplicate parameter names are invalid"
formula: "=LAMBDA(x,x,x+1)"
expected: "#VALUE!"related:
- LET
- IF
- SUM
faq:
- q: "Why does =LAMBDA(x,x+1) return #CALC! instead of a number?"
a: "LAMBDA returns a callable value. In a cell result position, it must be invoked, for example =LAMBDA(x,x+1)(1)."
- q: "Does a LAMBDA read outer LET variables at call time or definition time?"
a: "Definition time. The closure captures its lexical environment when created."
- q: "Can I call a LAMBDA with fewer or extra arguments?"
a: "No. Invocation arity must match the declared parameter count exactly, or #VALUE! is returned."[formualizer-docgen:schema:start]
Name: LAMBDA
Type: LambdaFn
Min args: 1
Max args: variadic
Variadic: true
Signature: LAMBDA(
fn name(&self) -> &'static str
fn min_args(&self) -> usize
fn variadic(&self) -> bool
Source§fn dispatch<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn dispatch<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
Dispatch to the unified evaluation path with automatic argument validation.
Source§fn eval<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn eval<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], _ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
The unified evaluation path. Read more
fn namespace(&self) -> &'static str
fn volatile(&self) -> bool
fn arg_schema(&self) -> &'static [ArgSchema]
Source§fn aliases(&self) -> &'static [&'static str]
fn aliases(&self) -> &'static [&'static str]
Optional list of additional alias names (case-insensitive) that should resolve to this
function. Default: empty slice. Implementors can override to expose legacy names.
Returned slice must have ’static lifetime (typically a static array reference).
fn function_salt(&self) -> u64
Source§fn eval_reference<'a, 'b, 'c>(
&self,
_args: &'c [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext<'b>,
) -> Option<Result<ReferenceType, ExcelError>>
fn eval_reference<'a, 'b, 'c>( &self, _args: &'c [ArgumentHandle<'a, 'b>], _ctx: &dyn FunctionContext<'b>, ) -> Option<Result<ReferenceType, ExcelError>>
Optional reference result path. Only called by the interpreter/engine
when the callsite expects a reference (e.g., range combinators, by-ref
argument positions, or spill sources). Read more
Auto Trait Implementations§
impl Freeze for LambdaFn
impl RefUnwindSafe for LambdaFn
impl Send for LambdaFn
impl Sync for LambdaFn
impl Unpin for LambdaFn
impl UnsafeUnpin for LambdaFn
impl UnwindSafe for LambdaFn
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more