For example, I pass the function name to another function
(personal-function 'func-name '(attr1 attr2 ...))
and what I want to do is
(defun personal-function (func-name)
(defun func-name '(attr1 attr2 ...) (dosomething)))
However, it said I can't defun
with a symbol... What should I do?
Calling a function from within itself is called recursion and the simple answer is, yes.
A function is called “nested” when it is created inside another function. It is easily possible to do this with JavaScript. Here the nested function getFullName() is made for convenience. It can access the outer variables and so can return the full name.
Use defun to define your own functions in LISP. Defun requires you to provide three things. The first is the name of the function, the second is a list of parameters for the function, and the third is the body of the function -- i.e. LISP instructions that tell the interpreter what to do when the function is called.
In Lisp, a symbol such as mark-whole-buffer has code attached to it that tells the computer what to do when the function is called. This code is called the function definition and is created by evaluating a Lisp expression that starts with the symbol defun (which is an abbreviation for define function).
Use
(setf (symbol-function my-symbol) some-function)
create a new function with
(compile nil (list 'lambda args body))
where args and body have meaningful values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With