XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

funcall


Type:   -   function (subr)
Source:   -   xlbfun.c

Syntax

(funcall function [arg1 ... ])
function - the function or symbol to be called
argN - an argument to be passed to function
returns - the result of calling the function with the arguments

Description

The 'funcall' function calls a function with a series of arguments. It returns the result from calling the function with the arguments.

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)                           ; set A
(setq b 3)                           ; 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)

See the funcall function in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next