emacs.d/clones/lisp/www.csci.viu.ca/~wesselsd/courses/csci330/code/lisp/funcall.cl.html
2022-10-07 19:32:11 +02:00

22 lines
610 B
HTML

#! /usr/bin/gcl -f
; (funcall 'function ...function arguments...)
; ---------------------------------------------
; given a function and a sequence of parameters,
; funcall can be used to apply the function to the arguments
; use funcall to evaluate (* 1 2 3 4)
(setf x (funcall '* 1 2 3 4))
; print the result
(format t "~A~%" x)
; function that takes a binary operator and two values as parameters
; and runs the function on the two values
(defun binRun (f a b)
(cond
((not (functionp f)) (format t "~A is not a function~%" f))
(t (funcall f a b))))
(binRun 'format t "hello!~%")