Alright thanks guys, really delved into this one this afternoon.
Even reached a gem from MIT :
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-10.html#%_sec_1.1.6Exercice 1.3, therin, was fun to do.
Simply
Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.
MIT so, no answers, this is what I came up with
(defun summed ( x1 x2 x3 / n1 n2 data)
(setq n1 (if (> x1 x2)
(* x1 x1)
(* x2 x2)
);if
);setq
(setq n2 (if (> x1 x3)
(* x1 x1)
(* x3 x3)
);if
);setq
(setq data (+ n1 n2))
)
Quick paste into cad and i'm pleasantly being returned these:
(_> (setq data (+ n1 n2)))
SUMMED
Command: (summed 1 2 3)
13
Command: (summed 2 4 3)
25
But alas, that's not mapcar, nor lambda. However, I did learn a crucial fact in understanding these that is often not touched on, I suppose it's one of those "taken for granted" or "should be fundamentally understood". That said, and being self-taught, I missed out until now on the fact that the original list is always within the mapcar statement, in fact it's the second argument so it has to be. Function to be applied to the list being the first. If the list is given in '(L I T E R A L) form or given as a variable1 has no affect on the function that is being applied to the list.
This is where I have to force myself to be careful. It won't be simple addition that a mapcar is accomplishing, as per 95% of the examples given with it. I understand the need for simplicity but it's confusing in it's own right
I'll have to take them symbolically in order to interchange the arithmetic with useful programming skills, for instance
(setq pt1 '(1.5 2.5 3.5))
(setq pt2 '(2.0 3.0 4.0))
(setq pt3 '(3.5 4.5 5.5))
(setq lst '(pt1 pt2 pt3) )
(defun getx ( pt /)
(if pt
(princ (car pt))
)
(princ)
)
(mapcar
'(lambda ( pt ) (if pt (princ (car pt)))
lst
)
Fails. Miserably. I thought that would work, when substituting lambda for the function that works if I do it (getx pt1) with those points defined.
Bah, need a short break, few hrs of this and an error. Try more soon..