hi,evgeniy, I use recursive method to do it
(defun ab (lst1 lst2 / res)
(foreach x lst1
(foreach y lst2
(if (atom y)
(setq y (list y))
)
(setq res (append
res
(list (cons x y))
)
)
)
)
res
)
(defun test (lst / res)
(if (= (cdr lst) nil)
(setq res (car lst))
(setq res (ab (car lst) (test (cdr lst))))
)
)
(setq l (list (list 1 2 3) (list 4 5 ) (list 6 7 8 9) (list 10 11)))
(test l)=>
((1 4 6 10) (1 4 6 11) (1 4 7 10) (1 4 7 11) (1 4 8 10) (1 4 8 11) (1 4 9 10) (1 4 9 11) (1 5 6 10) (1 5 6 11) (1 5 7 10) (1 5 7 11) (1 5 8 10) (1 5 8 11) (1 5 9 10) (1 5 9 11) (2 4 6 10) (2 4 6 11) (2 4 7 10) (2 4 7 11) (2 4 8 10) (2 4 8 11) (2 4 9 10) (2 4 9 11) (2 5 6 10) (2 5 6 11) (2 5 7 10) (2 5 7 11) (2 5 8 10) (2 5 8 11) (2 5 9 10) (2 5 9 11) (3 4 6 10) (3 4 6 11) (3 4 7 10) (3 4 7 11) (3 4 8 10) (3 4 8 11) (3 4 9 10) (3 4 9 11) (3 5 6 10) (3 5 6 11) (3 5 7 10) (3 5 7 11) (3 5 8 10) (3 5 8 11) (3 5 9 10) (3 5 9 11))
and if the l structure is different
like
(setq l '(((11))((21) (22))((31))))
the code maybe like as follow
(defun ab (lst1 lst2 / res)
(foreach x lst1
(foreach y lst2
(if (atom (car y))
(setq y (list y))
)
(setq res (append
res
(list (cons x y))
)
)
)
)
res
)
(defun test (lst / res)
(if (= (cdr lst) nil)
(setq res (car lst))
(setq res (ab (car lst) (test (cdr lst))))
)
)
(setq l '(((11))((21) (22))((31))))
(test1 l)===>
(((11) ((21) (31))) ((11) ((22) (31))))
(setq l '(((11)) ((21) (22))
((31)) ((41)(42)(43))
)
)
(test l)
===>
(((11) (21) (31) (41)) ((11) (21) (31) (42)) ((11) (21) (31) (43)) ((11) (22) (31) (41)) ((11) (22) (31) (42)) ((11) (22) (31) (43)))