Well, MP was faster and more elegant, but here is mine...
(defun c:recunfoldmatrix ( / matrix-n-m rec n m )
(defun matrix-n-m ( n m / nn mm itm row mat )
(setq nn 0)
(repeat n
(setq nn (1+ nn) mm 0)
(repeat m
(setq mm (1+ mm))
(setq itm (strcat (itoa nn) "-" (itoa mm)))
(setq row (cons itm row))
)
(setq mat (cons (reverse row) mat) row nil)
)
(reverse mat)
)
(defun rec ( mat / k itm1 itm2 kk lst )
(setq k -1)
(repeat (length mat)
(setq k (1+ k))
(setq itm1
(vl-remove-if-not '(lambda ( x ) (= (length x) 2))
(mapcar '(lambda ( x ) (setq kk (if (null kk) 2 (1+ kk))) (vl-remove-if-not '(lambda ( y ) (< (- kk 3) (vl-position y (nth k mat)) kk)) (nth k mat))) (nth k mat))
)
)
(setq kk nil)
(setq itm2
(vl-remove-if-not '(lambda ( x ) (= (length x) 2))
(mapcar '(lambda ( x ) (setq kk (if (null kk) 2 (1+ kk))) (vl-remove-if-not '(lambda ( y ) (< (- kk 3) (vl-position y (nth (1+ k) mat)) kk)) (nth (1+ k) mat))) (nth (1+ k) mat))
)
)
(setq kk nil)
(setq itm (mapcar '(lambda ( a b ) (append a b)) itm1 itm2))
(setq lst (cons itm lst))
)
(apply 'append (reverse lst))
)
(initget 7)
(setq n (getint "\nSpecify number of rows of matrix : "))
(initget 7)
(setq m (getint "\nSpecify number of columns of matrix : "))
(princ "\n")
(prin1 (rec (matrix-n-m n m)))
(princ)
)
;|
Command: RECUNFOLDMATRIX
Specify number of rows of matrix : 4
Specify number of columns of matrix : 7
(("1-1" "1-2" "2-1" "2-2") ("1-2" "1-3" "2-2" "2-3") ("1-3" "1-4" "2-3" "2-4") ("1-4" "1-5" "2-4" "2-5") ("1-5" "1-6" "2-5" "2-6") ("1-6" "1-7" "2-6" "2-7") ("2-1" "2-2" "3-1" "3-2") ("2-2" "2-3" "3-2" "3-3") ("2-3" "2-4" "3-3" "3-4") ("2-4" "2-5" "3-4" "3-5") ("2-5" "2-6" "3-5" "3-6") ("2-6" "2-7" "3-6" "3-7") ("3-1" "3-2" "4-1" "4-2") ("3-2" "3-3" "4-2" "4-3") ("3-3" "3-4" "4-3" "4-4") ("3-4" "3-5" "4-4" "4-5") ("3-5" "3-6" "4-5" "4-6") ("3-6" "3-7" "4-6" "4-7"))
|;