Hi,
I'm not sure to understand what you're trying to do, but you can define some functions
Thanks for the input gile, but unfortunately I'm aware of these techniques.
My question is more related about passing function to another, by using (multiple?) apostrophe/quote/function, i.e.: mapcar 'mapcar ... apply 'apply ...
if quoting confuses you, just use function instead
it will also speed up you code significantly
Thanks Vova, I didn't knew that
function is faster than quoting.
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
(((quote 2) (quote 2)) ("3" "4")) ; <- unexpected result
_$
(mapcar '
mapcar ''
(lambda (x
) (itoa x
)) '
((1 2)(3 4)(5 6))) ; another attempt - passing single (lambda) to the second (mapcar)(((quote 2) (quote 2)) ("3" "4")) ; <- unexpected result
_$
(mapcar ''
((x
) (mapcar '
itoa x
)) '
((1 2)(3 4)(5 6))) ; this works but, (x) acts like argument for the second (mapcar)(("1" "2") ("3" "4") ("5" "6")) ; <- expected result
Error: too few arguments ; ofcourse errors out, because no list argument is passed to the second (mapcar)
_1$
Or maybe including the subfunctions in the list using
cons :
(setq L '
((1 2)(3 4)(5 6)))
Hopefully you get the idea.
EDIT: I did not saw gile's second reply... will answer soon.
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:
(setq L '
((1 2) (3 4) (5 6) (7 9)))
Thanks again, Gile! :)