Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Remove NIL values in a LIST
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Remove NIL values in a LIST (Read 3616 times)
0 Members and 1 Guest are viewing this topic.
mailmaverick
Bull Frog
Posts: 493
Remove NIL values in a LIST
«
on:
September 05, 2016, 09:51:38 AM »
How to remove NIL values in a LIST ?
Logged
irneb
Water Moccasin
Posts: 1794
ACad R9-2016, Revit Arch 6-2016
WWW
Re: Remove NIL values in a LIST
«
Reply #1 on:
September 05, 2016, 10:04:42 AM »
Try:
http://help.autodesk.com/cloudhelp/2015/ENU/AutoCAD-AutoLISP/files/GUID-1BF33827-5C9C-49B2-A21B-656E0F429B21.htm#
!
Logged
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.
kpblc
Bull Frog
Posts: 396
Re: Remove NIL values in a LIST
«
Reply #2 on:
September 05, 2016, 10:36:22 AM »
(vl-remove nil lst)
Logged
Sorry for my English.
mailmaverick
Bull Frog
Posts: 493
Re: Remove NIL values in a LIST
«
Reply #3 on:
September 05, 2016, 11:04:25 AM »
Thanks a lot.
Sometimes we are so dumb
Logged
MP
Seagull
Posts: 17750
Have thousands of dwgs to process? Contact me.
WWW
Re: Remove NIL values in a LIST
«
Reply #4 on:
September 05, 2016, 11:25:06 AM »
Quote from: mailmaverick on September 05, 2016, 11:04:25 AM
Sometimes we are so dumb
(repeat 2 <game buzzer>)
Sorry, that is incorrect.
Not asking for help?
Now that would be dumb.
PS: The people you may consider gurus have asked LOTS of questions themselves.
Logged
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com
•
http://cadanalyst.slack.com
•
http://linkedin.com/in/cadanalyst
Lee Mac
Seagull
Posts: 12914
London, England
WWW
Re: Remove NIL values in a LIST
«
Reply #5 on:
September 05, 2016, 12:27:23 PM »
Some variations/benchmarks for academia:
Code - Auto/Visual Lisp:
[Select]
(
defun
remove
-
nil
-
1
(
lst
)
(
vl-remove
nil
lst
)
)
(
defun
remove
-
nil
-
2
(
lst
)
(
vl
-
remove
-
if
'
null
lst
)
)
(
defun
remove
-
nil
-
3
(
lst
)
(
apply
'
append
(
subst
nil
'
(
nil
)
(
mapcar
'
list
lst
)
)
)
)
(
defun
remove
-
nil
-
4
(
lst
)
(
apply
'
append
(
mapcar
'
(
lambda
(
x
)
(
if
x
(
list
x
)
)
)
lst
)
)
)
(
defun
remove
-
nil
-
5
(
lst
/
rtn
)
(
foreach
x lst
(
if
x
(
setq
rtn
(
cons
x rtn
)
)
)
)
(
reverse
rtn
)
)
(
defun
remove
-
nil
-
6
(
lst
)
(
if
lst
(
if
(
car
lst
)
(
cons
(
car
lst
)
(
remove
-
nil
-
6
(
cdr
lst
)
)
)
(
remove
-
nil
-
6
(
cdr
lst
)
)
)
)
)
Code - Auto/Visual Lisp:
[Select]
_$
(
setq
lst '
(
1
2
nil
3
4
nil
5
6
nil
)
)
(
1
2
nil
3
4
nil
5
6
nil
)
_$
(
repeat
4
(
setq
lst
(
append
lst lst
)
)
)
(
1
2
nil
3
4
nil
5
6
nil
1
2
nil
...
nil
5
6
nil
)
_$
(
length
lst
)
144
_$
(
benchmark '
(
(
remove
-
nil
-
1
lst
)
(
remove
-
nil
-
2
lst
)
(
remove
-
nil
-
3
lst
)
(
remove
-
nil
-
4
lst
)
(
remove
-
nil
-
5
lst
)
(
remove
-
nil
-
6
lst
)
)
)
Benchmarking ....................Elapsed milliseconds
/
relative speed for
131072
iteration
(
s
)
:
(
REMOVE
-
NIL
-
1
LST
)
.....
1669
/
5.16
<
fastest
>
(
REMOVE
-
NIL
-
2
LST
)
.....
2792
/
3.08
(
REMOVE
-
NIL
-
4
LST
)
.....
6723
/
1.28
(
REMOVE
-
NIL
-
3
LST
)
.....
6724
/
1.28
(
REMOVE
-
NIL
-
5
LST
)
.....
7379
/
1.17
(
REMOVE
-
NIL
-
6
LST
)
.....
8611
/
1.00
<
slowest
>
Logged
Lee Mac Programming
•
Twitter
•
Exchange App Store
Grrr1337
Swamp Rat
Posts: 812
WWW
Re: Remove NIL values in a LIST
«
Reply #6 on:
September 05, 2016, 01:48:34 PM »
This is
L
ee
M
ac right there, a.k.a. the
L
ist
M
anipulator. Thanks for posting this!
Logged
(apply ''((a b c)(a b c))
'(
(( f L ) (apply 'strcat (f L)))
(( L ) (if L (cons (chr (car L)) (f (cdr L)))))
(72 101 108 108 111 32 87 111 114 108 100)
)
)
vevo.bg
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Remove NIL values in a LIST