Remove the list if one of member equal to A
For example: I have a data list like below:
1,1,1,1
A,2,0,0
2,3,3,2
A,4,0,0
3,5,3,2
4,6,3,3
How to write the lisp code so that i can remove the list if there a member equal to A?
Then the list should return like below:
1,1,1,1
2,3,3,2
3,5,3,2
4,6,3,3
Thanks in advance.
Re: Remove the list if one of member equal to A
Something like this
Code:
_$ (setq lst '("1,1,1,1"
"A,2,0,0"
"2,3,3,2"
"A,4,0,0"
"3,5,3,2"
"4,6,3,3"))
("1,1,1,1" "A,2,0,0" "2,3,3,2" "A,4,0,0" "3,5,3,2" "4,6,3,3")
_$ (vl-remove-if '(lambda(x) (wcmatch(strcase x) "*A*")) lst)
("1,1,1,1" "2,3,3,2" "3,5,3,2" "4,6,3,3")
or
Code:
_$ (setq a 16.56)
16.56
_$ (setq lst (list '(1 1 1 1)
(list A 2 0 0)
'(2 3 3 2)
(list A 4 0 0)
'(3 5 3 2)
'(4 6 3 3)))
((1 1 1 1) (16.56 2 0 0) (2 3 3 2) (16.56 4 0 0) (3 5 3 2) (4 6 3 3))
_$ (vl-remove-if '(lambda(x) (vl-remove-if-not '(lambda(y) (equal y a)) x)) lst)
((1 1 1 1) (2 3 3 2) (3 5 3 2) (4 6 3 3))
I think so.
3 Attachment(s)
Re: Remove the list if one of member equal to A
Even I try too many time, I still cannot get the solution.
Attached here are my lisp code, dwg, csv file and xml file.
Please do try my code on my drawing.
What I want to remove are the list when value of column A in csv file equal to NC or DB.
Because of that value, a few rectangulars have been drawn at centre cross mark.
I dont want to draw the rectagular at centre cross mark.
Please help me modify my code. Thanks.
Re: Remove the list if one of member equal to A
One more:
Code:
(setq lst '(
(1 1 1 1)
(9 2 0 0)
(2 3 3 2)
(9 4 0 0)
(3 5 3 2)
(4 6 3 3)
)
)
(setq A 9)
(setq nlst (vl-remove-if '(lambda (x) (vl-position A x)) lst))