Hi Ramarren. When I seem dense, its not because of your english (which appears close to flawless to me anyway) its rather that your understanding of lisp is so much higher than mine that you take concepts for granted, which I can hardly even wrap my head around. Usually when I read your post the first time, I have no idea what you mean by it. After I have figured it out, it begins to dawn on me.
For example while this appeared completely cryptic when you first said it, it is now obvious. But I somehow had to experience it myself before I understood it.
You need to CONS a head (that is, a CAR) of list, appropriately modified, onto a tail (CDR) created by a recursive call to the tail of the argument.
-----
I thought reversing the result at the end was less elegent, as it seemed like "cheating". I get what you are saying about efficiancy though. Also, using t as the last condition makes sense. Anyway. I believe I have now understood everything you said until your last post. Your last post, again, is cryptic to me. I am confident, that I will understand it, as soon as I have figured out, but you are assuming that I know much more about programming in lisp (or programming in general) than I do. Sadly, at times I really need baby-talk it seems.
However I apreceate your help a whole lot. I just wrote a solution, which completely disregards your input - however, I think you are hinting at a more elegent solution, which I would like to figure out. I will try the last example and then come back to your input and give it another try.
Here is my solution
Code: Select all
(defun largest-smallest (lst &optional (small (car lst)) (large (car lst)))
(cond
((null lst) (+ small large))
((< (car lst) small) (largest-smallest (cdr lst) (set 'small (car lst) ) large))
((> (car lst) large) (largest-smallest (cdr lst) small(set 'large (car lst) )))
(t (largest-smallest (cdr lst) small large ))))
cheers
p.