defun-q-list-set

AutoCad AutoLISP Functions

 
defun-q-list-set
 
 
 

Sets the value of a symbol to be a function defined by a list

(defun-q-list-set 'sym
list)

Arguments

sym

A symbol naming the function

list

A list containing the expressions to be included in the function.

Return Values

The sym defined.

Examples

_$ (defun-q-list-set 'foo
'((x) x))
FOO
_$ (foo 3)
3

The following example illustrates the use of defun-q-list-set to combine two functions into a single function. First, from the Visual LISP Console window, define two functions with defun-q:

_$ (defun-q s::startup (x)
(print x))
S::STARTUP
_$ (defun-q my-startup (x)
(print (list x)))
MY-STARTUP

Use defun-q-list-set to combine the functions into a single function:

_$ (defun-q-list-set 's::startup
(append
         (defun-q-list-ref 's::startup)
    
         (cdr (defun-q-list-ref
'my-startup))))
    
S::STARTUP

The following illustrates how the functions respond individually, and how the functions work after being combined using defun-q-list-set:

_$ (defun-q foo (x) (print
(list 'foo x)))
FOO
_$ (foo 1)
(FOO 1) (FOO 1)
_$ (defun-q bar (x) (print
(list 'bar x)))
BAR
_$ (bar 2)
(BAR 2) (BAR 2)
_$ (defun-q-list-set
        'foo
    
        (append (defun-q-list-ref
'foo)
    
                    (cdr (defun-q-list-ref
'bar))
    
        ))
    
FOO
_$ (foo 3)
(FOO 3) 
(BAR 3) (BAR 3)
See Also