robierzo Posted September 11, 2012 Share Posted September 11, 2012 I need to add two lists. Add one to the list each member of the list2. The result would be the list3. (setq lista2 '((0.0 14.127) (10.314 6.634) (6.374 -5.491) (-6.374 -5.491) (-10.314 6.634))) (setq lista1 '(150.0 200.0)) The result: lista3 ((150.0 214.127) (160.314 206.634).......(139.686 206.634)) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 11, 2012 Share Posted September 11, 2012 (append (list lista1) lista2) Quote Link to comment Share on other sites More sharing options...
robierzo Posted September 11, 2012 Author Share Posted September 11, 2012 RenderMan, It's not right. You must use mapcar and lambda. But do not know how Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 11, 2012 Share Posted September 11, 2012 (foreach x lista2 (setq l (cons (list (+ (car x) (car lista1)) (+ (cadr x) (cadr lista1))) l))) (reverse l) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 11, 2012 Share Posted September 11, 2012 (mapcar '(lambda ( a ) (mapcar '+ a lista1)) lista2) Quote Link to comment Share on other sites More sharing options...
robierzo Posted September 11, 2012 Author Share Posted September 11, 2012 O.K. Thanks to all three. Lee Mac option is what I wanted. regards Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 11, 2012 Share Posted September 11, 2012 Respectfully, you neglected to specify the requirement for Mapcar and Lambda in your original post. I try not to suggest the more complex functions, when one neglects to demonstrate knowledge of the simpler (in this case Append)... Most certainly not because I think I know more than others, but simply that is how I learned. Second, had you tested the code I posted, you'd see that it does what you demonstrated in your original post (appending lista1 to the front of lista2). ... I stand corrected. Thankfully, other(s) have already answered your question, given the supplemental criteria. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 11, 2012 Share Posted September 11, 2012 Second, had you tested the code I posted, you'd see that it does what you demonstrated in your original post (appending lista1 to the front of lista2). Look a little closer at the OP's requirement Renderman - the solution that you proposed is not equivalent to the others posted in this thread. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 11, 2012 Share Posted September 11, 2012 Post corrected. Quote Link to comment Share on other sites More sharing options...
robierzo Posted September 11, 2012 Author Share Posted September 11, 2012 Sorry. My English is the English translator of Google. It is archaic and poor, but I do not know more. I express myself best I can. Thank you. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 12, 2012 Share Posted September 12, 2012 Sorry. My English is the English translator of Google. It is archaic and poor, but I do not know more. I express myself best I can. Thank you. Perhaps I failed to consider that when posting my reply. Please know that I mean no offense. I was hasty, and mistaken. I genuinely am glad that you received the help you were looking for, even if I did not properly understand the request. I will try to pay more attention to this fact in the future. Cheers! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.