Maybe this:Code - Auto/Visual Lisp: [Select]
(setq lst '( ("1." ("1.1" ("1.1.1" ("1.1.1.1" "1.1.1.2" "1.1.1.3") ) ("1.1.2" ("1.1.2.1" "1.1.2.2" "1.1.2.3") ) ) ("1.2" ("1.2.1" ("1.2.1.1" "1.2.1.2" "1.2.1.3") ) ("1.2.2" ("1.2.2.1" "1.2.2.2" "1.2.2.3") ) ) ) ("2." ("2.1" ("2.1.1" ("2.1.1.1") ) ) ) ) ) ; (substADV lst 2 "test") (cond ((= cur n) new) (T itm) ) ) lst ) ) (N_subst lst 0) )
(setq lst1
(list
(list "Women"
(list "Jacket"
(list "XS"
(list "Red" "Yellow" "Blue")
)
(list "S"
(list "White" "Green" "Blue")
)
)
(list "Dress"
(list "XS"
(list "Cyan" "Yellow")
)
(list "S"
(list "Black" "Green" "Blue")
)
)
)
(list "Men"
(list "Jacket"
(list "S"
(list "White" "Yellow" "Blue")
)
(list "M"
(list "White" "Black" "Blue")
)
)
(list "Chino"
(list "31"
(list "Cyan" "Yellow")
)
(list "32"
(list "Black" "Blue")
)
)
)
)
)
(substADV-Alt lst1 2 "NEW") => (("Women" ("NEW" "NEW" "NEW") ("NEW" "NEW" "NEW")) ("Men" ("NEW" "NEW" "NEW") ("NEW" "NEW" "NEW")))
Hmm, after re-reading I think you probably want this:Code - Auto/Visual Lisp: [Select]
(cond ((= cur n) new) (T itm) ) ) lst ) ) (N_subst lst 0) )
Edit:
Actually the examples are confusing. In the first post it would seem that atoms and sublists at the same nesting level n should all be replaced. The substADV-Alt function will do this. But its results do not match the OP's last post.Code: [Select](setq lst1
(list
(list "Women"
(list "Jacket"
(list "XS"
(list "Red" "Yellow" "Blue")
)
(list "S"
(list "White" "Green" "Blue")
)
)
(list "Dress"
(list "XS"
(list "Cyan" "Yellow")
)
(list "S"
(list "Black" "Green" "Blue")
)
)
)
(list "Men"
(list "Jacket"
(list "S"
(list "White" "Yellow" "Blue")
)
(list "M"
(list "White" "Black" "Blue")
)
)
(list "Chino"
(list "31"
(list "Cyan" "Yellow")
)
(list "32"
(list "Black" "Blue")
)
)
)
)
)
(substADV-Alt lst1 2 "NEW") => (("Women" ("NEW" "NEW" "NEW") ("NEW" "NEW" "NEW")) ("Men" ("NEW" "NEW" "NEW") ("NEW" "NEW" "NEW")))