CANDOWE Posted September 7 Share Posted September 7 original lists: (setq list1 '(a b c)) (setq list2 '(x y z)) results should be like this: (setq list3 '('(a x) '(a y) '(a z) '(b x) '(b y) '(b z) '(c x) '(c y) '(c z)) Quote Link to comment Share on other sites More sharing options...
exceed Posted September 7 Share Posted September 7 (edited) (defun c:test ( / list1 list2 whatyouwant) (setq list1 '("a" "b" "c")) (setq list2 '("x" "y" "z")) (defun ex:combinelist ( la lb / lal lbl lo indexa indexb ) (setq lo '()) (setq lal (length la)) (setq lbl (length lb)) (setq indexa 0) (repeat lal (setq indexb 0) (repeat lbl (setq lo (cons (list (nth indexa la) (nth indexb lb)) lo)) (setq indexb (+ indexb 1)) ) (setq indexa (+ indexa 1)) ) (reverse lo) ) (setq whatyouwant (ex:combinelist list1 list2)) (princ whatyouwant) (princ) ) Edited September 7 by exceed Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 7 Share Posted September 7 (apply 'append (mapcar '(lambda ( x ) (mapcar '(lambda ( y ) (list x y)) list2)) list1)) 2 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.