Jump to content

Recommended Posts

Posted (edited)

Can you help me to filter all values from a list, which between given two values.

eg. all values between 50 and 75.(THANKS EVERYBODY I GOT THE ANSWER)

Edited by wimal
Posted

Welcome to the forum .

 

What's these values and where you want to filter them from ?

 

Tharwat

Posted

This values are from a cross section of a road.

I want to filter the levels 2m distance to both sides from center of the road.

Thanks for replying me. I think you can help me. wimal

Posted
Welcome to the forum .

 

What's these values and where you want to filter them from ?

 

Tharwat

 

^^ Once again ^^

Posted

These values are feeding to AUTO lisp program through a (DCL) dialog box. (distances & levels separately) Distances are given from center line of the road. I need to filter the levels within 2m distance from road cl.

Distance from road cl. D1,D2,D3,D5 etc. & Relevant Levels L1,L2;L3,L4 etc. I need to separate levels between L= -2.0m and L = +2.0m

Posted (edited)

Not sure what you mean by Values, but if its a list of numeric values

 
(setq lst '(1.5 1.75 2.34 1.54 2.00 2.25 1.23))

(defun HiLow (lst num / a b)    
(setq a (vl-remove-if-not
      '(lambda (v) (< v 2))
      lst)
       b
    (vl-remove-if-not
      '(lambda (v)(>= v 2))
      lst
    )
 )
 (print a)
 (print b)
 (princ)
 )

 

 
(defun HiLow2 (lst num / a b)
 (foreach itm lst 
   (if (>= itm num)

     (setq b (cons itm b))
     (setq a (cons itm a))
   )
 )
 (print a)
 (print b)
 (princ)
)

 

(defun HiLow3 (lst num / x y a b)
(while (setq x (car lst))
   (if (>= x num)
    (setq b (cons x b))
    (setq a (cons x a))
   )
(setq lst (cdr lst))
 )
 (print a)
 (print b)
 (princ)
)

 

(HiLow lst 2)

(HiLow2 lst 2)

(HiLow3 lst 2)

 

where would 2.00 go? hi or low :)

Edited by pBe

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...