Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

funcall

funcall

type: function (subr) 
location: built-in
source file: xlbfun.c
Common LISP compatible: yes
supported on: all machines

SYNTAX

(funcall <function> [<arg1> ... ] )
        <function>      -       the function or symbol to be called
        <argN>          -       an argument to be passed to <function>

DESCRIPTION

FUNCALL calls a function with a series of arguments. FUNCALL returns the result from <function>.

EXAMPLES

(funcall '+ 1 2 3 4)                    ; returns 10
(funcall #'+ 1 2 3 4)                   ; returns 10
(funcall '+ '1 '2 '3)                   ; returns 6
(setq sys-add (function +))             ; returns #<Subr-+: #22c32>
(setq a 99)                             ;
(funcall sys-add 1 a)                   ; 100
(funcall sys-add 1 'a)                  ; error: bad argument type
                                        ;   you can't add a symbol
                                        ;   only it's value
(setq a 2)      (setq b 3)              ; set A and B values
(funcall (if (< a b) (function +)       ; <function> can be computed
                     (function -))      ;
         a b)                           ; returns 5
(defun add-to-list (arg list)           ; add a list or an atom
   (funcall (if (atom arg) 'cons        ;   to the front of a list
                           'append)     ;
            arg list))                  ;
(add-to-list 'a '(b c))                 ; returns (A B C)
(add-to-list '(a b) '(b c))             ; returns (A B B C)


Go to the first, previous, next, last section, table of contents.