wimal Posted October 7, 2011 Posted October 7, 2011 (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 October 7, 2011 by wimal Quote
Tharwat Posted October 7, 2011 Posted October 7, 2011 Welcome to the forum . What's these values and where you want to filter them from ? Tharwat Quote
wimal Posted October 7, 2011 Author Posted October 7, 2011 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 Quote
Tharwat Posted October 7, 2011 Posted October 7, 2011 Welcome to the forum . What's these values and where you want to filter them from ? Tharwat ^^ Once again ^^ Quote
wimal Posted October 7, 2011 Author Posted October 7, 2011 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 Quote
pBe Posted October 7, 2011 Posted October 7, 2011 (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 October 7, 2011 by pBe Quote
Recommended Posts
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.