M76 Posted October 21, 2009 Posted October 21, 2009 Is there an equivalent of the common "in" function within autolisp? I mean when I have a parameter and I want to check if it is contained within a list of other parameters. For example: "1" in "3" "4" "5" would return false "4" in "3" "4" "5" would return true ??? Quote
MSasu Posted October 21, 2009 Posted October 21, 2009 Use the MEMBER statement – should apply it on a list: (member "1" '(3" "4" "5")) return nil (False) (member "4" '("3" "4" "5")) return T (True) Regards, Quote
MSasu Posted October 21, 2009 Posted October 21, 2009 Have made one mistake: the MEMBER statement will not return T but the part of list following the tested item. Sorry for inconvenience. However if require T may write your own IN function: (defun in( theItem theList / ) (if (member theItem theList) T) ) Regards, Quote
alanjt Posted October 21, 2009 Posted October 21, 2009 Have made one mistake: the MEMBER statement will not return T but the part of list following the tested item. Sorry for inconvenience. However if require T may write your own IN function: (defun in( theItem theList / ) (if (member theItem theList) T) ) Regards, Another way to skin the cat: (defun in (theItem theList) (and (member theItem theList))) 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.