TobyKanoby
2007-06-16, 12:30 AM
Is there an easy way to find if list items are the same?
With "=" I get the following return.
Command: (= 2.5 2.5 2.5) = T
Command: (= 2.5 2.7 2.5) = nil
Command: (setq lst1 (list 2.5 2.5 2.5)) = '(2.5 2.5 2.5)
Command: (setq lst2 (list 2.5 2.7 2.5)) = '(2.5 2.7 2.5)
Command: (progn(setq same t)(foreach num lst1(if(/= num(car lst1))(setq same nil)))same) = T
Command: (progn(setq same t)(foreach num lst2(if(/= num(car lst2))(setq same nil)))same) = nil
Then I came across this vl-every function.
Command: (vl-every '= lst1 (cdr lst1)) = T
Command: (vl-every '= lst2 (cdr lst2)) = nil
Is this the best function to use?
With "=" I get the following return.
Command: (= 2.5 2.5 2.5) = T
Command: (= 2.5 2.7 2.5) = nil
Command: (setq lst1 (list 2.5 2.5 2.5)) = '(2.5 2.5 2.5)
Command: (setq lst2 (list 2.5 2.7 2.5)) = '(2.5 2.7 2.5)
Command: (progn(setq same t)(foreach num lst1(if(/= num(car lst1))(setq same nil)))same) = T
Command: (progn(setq same t)(foreach num lst2(if(/= num(car lst2))(setq same nil)))same) = nil
Then I came across this vl-every function.
Command: (vl-every '= lst1 (cdr lst1)) = T
Command: (vl-every '= lst2 (cdr lst2)) = nil
Is this the best function to use?