; Using single lambda and multiple quoting
; is it possible to ... (mapcar 'mapcar ''mapcar '''(lambda (x) (foo x) lst))
; mapcar 'mapcar ???
(mapcar '(lambda (a) (mapcar '(lambda (b) (foo b)) a)) lst)
; mapcar 'mapcar ''mapcar ???
(mapcar
'(lambda (a)
(mapcar
'(lambda (b)
(mapcar
'(lambda (c)
(foo c)
); lambda (c)
b
); mapcar
); lambda (b)
a
); mapcar
); lambda (a)
lst
); mapcar
but when it comes to double or tripple apostrophing/quoting - I'm getting lost by the order of evaluations. :thinking:if quoting confuses you, just use function instead
Hi,
I'm not sure to understand what you're trying to do, but you can define some functions
if quoting confuses you, just use function instead
it will also speed up you code significantly
EDIT2:
Ok, now I understand (actually I'm always forgetting that second way of use of mapcar - Lee showed it to me some time ago).
So the second (not so good) approach would be:Code - Auto/Visual Lisp: [Select]
You could also write it like this:Code - Auto/Visual Lisp: [Select]
And Cryptic should to be avoided at all times.
My 2 cents.
Maybe a 'mapatom' solution is what is called for here:
Maybe a 'mapatom' solution is what is called for here:
Hi Roy,
Not really.. the task is more like mapping to the "nth" level:Code - Auto/Visual Lisp: [Select]
; Given a list: ; Define a function (foo): ; (foo n fun Lst) ; n - level to map ; fun - function to map ; list - to be mapped (foo 0 fun Lst) ; would map fun to items : (("A" "B") ("C" "D")) and (("E" "F") ("G" "H")) (foo 1 fun Lst) ; would map fun to items : ("A" "B") ("C" "D") ("E" "F") and ("G" "H") (foo 2 fun Lst) ; would map fun to items : "A" "B" "C" "D" "E" "F" "G" and "H"
This looks like a challenge. :)
Anyway the atom mapping was also discussed here (https://www.theswamp.org/index.php?topic=52673.msg575562#msg575562).
Ok, let me restructure my question:
Is it possible to pass mapcar function to another mapcar function, without using:
- More than one (lambda)
- Subfunction (defun)
- Recursion
Just have a look at my first reply, I tried to make the function name self explanatory):
(foo 0 fun lst) => (mapcar fun lst) i.e. map the car level
(foo 1 fun lst) => (mapcaar fun lst) i.e. map the caar level
(foo 2 fun lst) => (mapcaaar fun lst) i.e. map the caaar level
You could also write it like this:Code - Auto/Visual Lisp: [Select]
Note that: (mapncar 0 (lambda (x) (reverse x)) Lst) can become: (mapncar 0 reverse lst)
Thanks Grrr.
Note that: (mapncar 0 (lambda (x) (reverse x)) Lst) can become: (mapncar 0 reverse lst)
Lee, is there any reason you prefer use non-quoted function as argument in higher order functions? What's wrong with built in AutoLISP functions standard quoted ones?