CANDOWE Posted September 7, 2023 Posted September 7, 2023 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
exceed Posted September 7, 2023 Posted September 7, 2023 (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, 2023 by exceed Quote
Lee Mac Posted September 7, 2023 Posted September 7, 2023 (apply 'append (mapcar '(lambda ( x ) (mapcar '(lambda ( y ) (list x y)) list2)) list1)) 2 Quote
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.