Kowal Posted July 3, 2013 Share Posted July 3, 2013 Hi, I need a arguments function that sums the two lists. Example (setq lst1 (list (list 1 2 3 …) (list 2 3 4 …) (list 5 4 3 …) …)) (setq lst2 (list (list 4 4 4 …) (list 1 1 1 …) (list 3 3 3 …) …)) Result ((5 6 7 …) (3 4 5 …) (8 7 6 …) …) Lists are symmetric but have any length. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 3, 2013 Share Posted July 3, 2013 (defun f ( l1 l2 ) (mapcar '(lambda ( x y ) (mapcar '+ x y)) l1 l2)) _$ (f '((1 2 3) (2 3 4) (5 4 3)) '((4 4 4) (1 1 1) (3 3 3))) ((5 6 7) (3 4 5) (8 7 6)) Quote Link to comment Share on other sites More sharing options...
Kowal Posted July 4, 2013 Author Share Posted July 4, 2013 Thank you. Quote Link to comment Share on other sites More sharing options...
fixo Posted July 4, 2013 Share Posted July 4, 2013 Another way, recursive (defun plus_lists (lst1 lst2 / ) ;;FH 2009 (if (and lst1 lst2) (append (plus_lists (reverse (cdr (reverse lst1)))(reverse (cdr (reverse lst2)))) (list (mapcar '+ (last lst1) (last lst2))) ))))) ;;usage : (setq summlst (plus_lists lst1 lst2)) Quote Link to comment Share on other sites More sharing options...
DaveC Posted January 6, 2017 Share Posted January 6, 2017 Hello everyone... I need your help.. I need to add the path to a dwg list... (setq DWG_PATH_lst ("c:/test/")) ; (setq DWG_List ("a1" "a2")) ; the result must be a new list ===>>> ("c:/test/a1" "c:/test/a2") please help... thank in advance Quote Link to comment Share on other sites More sharing options...
DaveC Posted January 6, 2017 Share Posted January 6, 2017 got it... 1. Make sure DWG_PATH_lst is a string... (setq New-DWG_List (mapcar '(lambda ( x ) (strcat DWG_PATH_lst x)) DWG_List)) 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.