lambda

AutoCad AutoLISP Functions

 
lambda
 
 
 

Defines an anonymous function

(lambda arguments expr...) 

Use the lambda function when the overhead of defining a new function is not justified. It also makes your intention more apparent by laying out the function at the spot where it is to be used. This function returns the value of its last expr, and is often used in conjunction with apply and/or mapcar to perform a function on a list.

Arguments

arguments

Arguments passed to an expression.

expr

An AutoLISP expression.

Return Values

Value of the last expr.

Examples

The following examples demonstrate the lambda function from the Visual LISP Console window:

_$ (apply '(lambda (x y
z) 
                (* x (- y z)) 
    
              ) 
    
              '(5 20 14) 
    
      )
    
30
_$ (setq counter 0)
      (mapcar '(lambda (x) 
    
                (setq counter
(1+ counter)) 
    
                (* x 5) 
    
              ) 
    
              '(2 4 -6 10.2) 
    
      )
    
0
(10 20 -30 51.0)