Author Topic: Are you a MEMBER?  (Read 2378 times)

0 Members and 1 Guest are viewing this topic.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Are you a MEMBER?
« on: December 08, 2005, 07:04:32 AM »
Quote
What can you do with the MEMBER function?

Well let's see ...
Code: [Select]
(setq lst '( 1.0 2.25 3.15 5 0.25 ))
(member 2.25 lst)
==> (2.25 3.15 5 0.25)

(car (member 2.25 lst))
==> 2.25

(member (+ 2.5 2.5) lst)
==> (5 0.25)


That's pretty cool uh.

Code: [Select]
(setq i '((1 2 3)(4 5 6)("a" "b" "c")))

(member '(4 5 6) i)
==> ((4 5 6) ("a" "b" "c"))

(member 5 (car (member '(4 5 6) i)))
==> (5 6)


(defun c:vote (/ answers question)
  (setq answers '("yes" "no" "maybe"))

  (setq question (getstring "\nDo you like ACAD 2006? "))

  (if (member (strcase question t) answers)
    (princ "\nThanks for voting")
    (princ
      "\nSorry I can only accept \"yes\" \"no\" or \"maybe\""
    )
  )
  (princ)

)
TheSwamp.org  (serving the CAD community since 2003)

nivuahc

  • Guest
Re: Are you a MEMBER?
« Reply #1 on: December 08, 2005, 07:10:34 AM »
Hope you don't mind, I updated your code a bit:

Code: [Select]
(defun c:vote (/ answers question)
  (setq answers '("yes" "no" "maybe"))

  (setq question (getstring "\nDo you like ACAD 2006? "))

  (if (member (strcase question t) answers)
    (princ "\nThanks for voting")
    (princ
      "\nPlease refrain from using expletives and answer \"yes\" \"no\" or \"maybe\" only"
    )
  )
  (princ)

)

Code: [Select]
command: vote
Do you like ACAD 2006?  It's driving me up the $%#*@ WALL!!!!!
Please refrain from using expletives and answer "yes" "no" or "maybe" only
command:

hudster

  • Gator
  • Posts: 2848
Re: Are you a MEMBER?
« Reply #2 on: December 08, 2005, 07:21:40 AM »
 :-D
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

whdjr

  • Guest
Re: Are you a MEMBER?
« Reply #3 on: December 08, 2005, 08:14:39 AM »
Catchy title Mark.  :-)

Joe Burke

  • Guest
Re: Are you a MEMBER?
« Reply #4 on: December 08, 2005, 09:17:03 AM »
Member if you need the list it returns. Otherwise, vl-position to simply test for an item in a list.