Structure - λ; - Lambda Function

Characters: λ , ;

Tags: function

The beginners' page has a general explanation of Vyxal structures and syntax.

Functionality

Create a lambda function (pushes an anonymous function to the stack).

Details

λarity|code; defines a lambda function with a given arity. λcode; sets a default arity of 1. When a lambda is applied with (Call Function Reference), it pops that many values from the current stack and places them on its stack in reverse order (the last popped element becomes the TOS). Then, the function body is run on that sub-stack. Finally, if the stack is non-empty, its top value gets pushed back to the stack in which the function was called; otherwise, the original TOS is pushed back.