I am writing a procedure that contains a decent sized cond statement. What would make it larger than it needs to be, would be if I had to add to each condition an "OR" statement and place each size within each condition, like so: (cond ((= (or (beamsize "813") (= beamsize "815")(etc.)) udsize)(info here))
. SO..... I went in search of a way to group these sizes into lists and use mapcar to give me T/nil values. That works, so I figured member ought to be able to return any true values or nil if nil. I got that working and found myself with a list (T). This won't work with cond like this: (cond ((T)()), then I remembered car will give me the first element of a list and since there should only be one element when member's done, I tried it and got the desired results. Here's the partial code:
(car (member 'T (mapcar '(lambda (x) (= pocket x)) sizelist)))
pocket is a user-supplied argument and sizelist is a list of beam sizes that can be placed into the same size pocket. Ex.
(setq sizelist (list "813" "815" "818")). Mapcar compares pocket with sizelist and returns T or nil.
Pretty cool, eh?