Jump to content

Recommended Posts

Posted (edited)

Hello. I need to convert two lists with mapcar, lambda.....

Example:

 
(setq lista '((1.236 (5 10)) (5.3214 (4 9)) (7.6541 (12 63))))

Convert to:

 
'((5 10) (4 9) (12 63))

Is that possible?

Can not be used FOREACH!!!

Regards

Edited by robierzo
Posted

Try this ...

 

(mapcar (function (lambda (x) (setq l (cons (cdr x) l)))) '((1.236 (5 10)) (5.3214 (4 9)) (7.6541 (12 63))))
(apply 'append (reverse l))

 

With the use of foreach function .

 

(foreach x '((1.236 (5 10)) (5.3214 (4 9)) (7.6541 (12 63))) (setq lst (cons (cdr x) lst)))
(apply 'append (reverse lst))

Posted
(setq lista '((1.236 (5 10)) (5.3214 (4 9)) (7.6541 (12 63))))
(mapcar	(function (lambda (x) (cadr x)))
lista
)

Posted

jajajaja. Very very very great, Lee.

I guess it can not be reduced further. jejeje

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...