Thanks for the reply... I learned most of what you posted when I started learning about closures, but hey, since I'm still a n00b, better
sage than sorry. I had to look at the situation for myself and realized that I had to approach the problem in pieces. On the webpage I posted above:
Code: Select all
(defun smaller (x y)
(if (< x y) x y)) ;; is equivalent to =>
(lambda (x)(lambda (y) (if (< x y) x y))) ;; which yields =>
(funcall (funcall(function (lambda (x) (function (lambda (y) (if (< x y) x y)))) )4)9) ;; returns =>4
Not life threatening, so I tried this:
Code: Select all
(funcall (funcall #'(lambda(x)#'(lambda(y)(if (< x y) x y)))4)9) ;; different syntax, returns =>4
(funcall (funcall #'(lambda(p)#'(lambda(q)(* (funcall q 5) p)))8)#'sqrt);; note position of variables during application. returns => 17.888544
Which makes more sense to me. However I'm still having trouble with the original problem:
Code: Select all
(defun d(a b)
(* a b)) ;; see below
(funcall (funcall #'(lambda(a)#'(lambda(b)#'(lambda(m)(funcall m a b)))#'d)8)9) ;; note the change in position for variable application.
returns => too few arguments to D
I couldn't see what was going on in the stepper with just
#'*, so I had to introduce
#'d . So if you could help with this, it would really help. Thanks again.
m.