TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: dubb on October 23, 2018, 12:23:22 PM
-
I'm having a bit of a misunderstanding on how this works.
(setq lst '("A" "B" "C"))
(subst '("1") '("A") lst)
Autodesk website shows an example of how it works but I'm not getting the results I need.
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-AutoLISP/files/GUID-25214E69-090A-45C3-8210-6D9801255E44-htm.html
:uglystupid2:
-
For example:
_$
(setq lst '
("A" "B" "C"))("A" "B" "C")
("A" "1" "C")
Be aware that subst will replace all occurrences of item in a list:_$
(setq lst '
("A" "B" "C" "B" "C"))("A" "B" "C" "B" "C")
("A" "1" "C" "1" "C")
-
Wow! That's it! So I missed it by treating each subst item as a list instead of a string.
For example:_$
(setq lst '
("A" "B" "C"))("A" "B" "C")
("A" "1" "C")
Be aware that subst will replace all occurrences of item in a list:_$
(setq lst '
("A" "B" "C" "B" "C"))("A" "B" "C" "B" "C")
("A" "1" "C" "1" "C")
-
Wow! That's it! So I missed it by treating each subst item as a list instead of a string.
Indeed - though, the subst item can be a list if that is what your list contains, e.g.:
_$
(setq lst '
(("A") ("B") ("C")))(("A") ("B") ("C"))
_$
(subst '
("1") '
("B") lst
)(("A") ("1") ("C"))
-
Awesome! I love it. Thank you for enlightening me.
Wow! That's it! So I missed it by treating each subst item as a list instead of a string.
Indeed - though, the subst item can be a list if that is what your list contains, e.g.:
_$
(setq lst '
(("A") ("B") ("C")))(("A") ("B") ("C"))
_$
(subst '
("1") '
("B") lst
)(("A") ("1") ("C"))