Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Convert numbers in a list to nil when meet conditions?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
maikhanhmst
364 Views, 2 Replies

Convert numbers in a list to nil when meet conditions?

Hi,

 

I want to convert the numbers that less than 2.5 and greater than 4.5 to nil. Could someone help me to do it?

The list: (setq a '(0 1 2 3 4 5)).

The result I want to get: (nil nil nil 3 4 nil).

 

Thanks.

2 REPLIES 2
Message 2 of 3
Kent1Cooper
in reply to: maikhanhmst

[As in the other thread...]  One way:

 

(mapcar '(lambda (x) (if (<= 2.5 x 4.5) x)) a)

Kent Cooper, AIA
Message 3 of 3
maikhanhmst
in reply to: Kent1Cooper

Perfect!!! Thank you so much.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost