I'm trying to figure out how Common Lisp deals with functions. If I do something like
(defun square (n)
(* n n))
I can later call, for example, (square 10). However, if I do something like
(defun reapply (fun)
(lambda (n)
(funcall fun (funcall fun n))))
and then define
(defparameter to-the-fourth (reapply #'square))
the function to-the-fourth can not be called as (to-the-fourth 10); I instead have to write (funcall to-the-fourth 10). I think that's because defparameter defines variables in the variable namespace rather than the function namespace. Is there any way to define a function in the function namespace? The following seems pretty verbose:
(defun to-the-fourth (a)
(funcall (reapply #'square) a))
(defvar square (n) (* n n))is not valid Common Lisp code. There is also no,in Common Lisp at the end of Lisp forms.defunform lacks closing parentheses and(n)in the function body is not valid code, sincenis not a function. Then(reapply square)also does not work, since the variablesquareis undefined.