gsc Posted March 18 Share Posted March 18 Hi, I have a list (tmp_list1) that may contains at least 1 or more of the following strings: 00-Structure Safety Zone-temp 01-Create IAC-Safety Zones-temp 02-Create Scour Protections-temp 03-Create Archaeological Areas-temp 04-Create Maintenance Zones-temp 05-Create Seabed Steep Slope Areas-temp 06-Create Rock Steep Slope Areas-temp 07-Create Sediment Thickness-temp With a foreach function I want to compare per string, 1 by 1 whether the string equals 1 of the 3 expressions in the condition However, for the 2nd and 3rd expressions, the value of the string must equal 1 of those (3 or 4) possibilities. I thought I could achieve this with the OR function, but this apparently does not work. What am I doing wrong here? (foreach itm tmp_lst1 (cond ((equal (car itm) "00-Structure Safety Zone-temp") (print (strcat "this is " (car itm))) ) ((or (equal (car itm) "01-Create IAC-Safety Zones-temp") (equal (car itm) "02-Create Scour Protections-temp") (equal (car itm) "03-Create Archaeological Areas-temp") (equal (car itm) "04-Create Maintenance Zones-temp") ) (print (strcat "this is " (car itm))) ) ((or (equal (car itm) "05-Create Seabed Steep Slope Areas-temp") (equal (car itm) "06-Create Rock Steep Slope Areas-temp") (equal (car itm) "07-Create Sediment Thickness-temp") ) (print (strcat "this is " (car itm))) ) ) ;end cond ) ;end foreach Quote Link to comment Share on other sites More sharing options...
rlx Posted March 18 Share Posted March 18 maybe : (defun t1 ( / tmp-lst ) (setq tmp_lst1 '("00-Structure Safety Zone-temp" "01-Create IAC-Safety Zones-temp" "02-Create Scour Protections-temp" "03-Create Archaeological Areas-temp" "04-Create Maintenance Zones-temp" "05-Create Seabed Steep Slope Areas-temp" "06-Create Rock Steep Slope Areas-temp" "07-Create Sediment Thickness-temp")) (foreach itm tmp_lst1 (cond ((equal itm "00-Structure Safety Zone-temp") (print (strcat "this is " itm))) ((member itm '("01-Create IAC-Safety Zones-temp" "02-Create Scour Protections-temp" "03-Create Archaeological Areas-temp" "04-Create Maintenance Zones-temp")) (print (strcat "this is " itm))) ((member itm '("05-Create Seabed Steep Slope Areas-temp" "06-Create Rock Steep Slope Areas-temp" "07-Create Sediment Thickness-temp")) (print (strcat "this is " itm))) ) ) ) You keep comparing (car itm) for every member in list... Quote Link to comment Share on other sites More sharing options...
gsc Posted March 19 Author Share Posted March 19 Thanx, your'e right, this works more efficient Quote Link to comment Share on other sites More sharing options...
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.