VL-remove (리스트에서 요소제거하기)

Auto CAD/lisp|2019. 4. 4. 14:27
(vl-remove 인수 리스트)

 

 특정 리스트에서 어떤 요소를  제거할때 좋습니다.

 

example)

 

_$ (vl-remove "a" (list "a" "a" "a" "b" "c" "a"))
("b" "c")
_$ (vl-remove "안녕" (list "안녕" "하이" "ㅋㅋ"))
("하이" "ㅋㅋ")

 

리스트안에 해당 인수는 모두 제거를 해주고 리스트로 응답이 됩니다. 

문자열 공백제거 할대 쓰면 좋겟져.^^

 

(defun @TextGapDelete(txt / txt)
 (setq txt (apply 'strcat (mapcar 'chr (vl-remove 32 (vl-string->list txt)))))
txt)

 

공백열 제거 서브루틴입니다.

 

(vl-string->list txt) 로 하면.. ascii 코드로 문자를 변환시켜서 리스트화합니다.

여기서 ascii코드 32는 공백열.. 즉. 해당 아스키코드리스트에서 공백을 다 제거하는것입니다. 

 

출처 : 아키모아 행복한 하루  http://cafe.daum.net/archimore/IP9e/56

 

 

(defun mmde(old_lst / new_lst cod no)
(setq new_lst '())
(setq cod t)
(while cod
(setq tmp (nth 0 old_lst))
(setq new_lst (append new_lst (list tmp)))
(setq old_lst (vl-remove tmp old_lst))
(setq no (length old_lst))
(if (= no 0) (setq cod nil))
)
new_lst
)

'Auto CAD > lisp' 카테고리의 다른 글

Mapcar & Lambda  (0) 2021.02.20
달수 ▷ ActiveX 처음 시작하기전에 읽어보세요  (2) 2019.04.05
vla-ZoomScaled (메써드)  (0) 2019.04.04
vla-ZoomCenter (메써드)  (0) 2019.04.04
vla-ZoomAll (메써드)  (0) 2019.04.04

댓글()