|
Welcome, Guest.
|
||||||
| AutoLISP AutoLISP or Visual LISP, learn both here! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
I could stop if I wanted to
Join Date: 2003-05
Posts: 335
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Can someone refresh my memory as to what function is used to remove duplicate strings from a list.
I'm having a brain fart this morning. Thanks, Will |
|
|
|
|
|
#2 |
|
100 Club
Join Date: 2000-12
Posts: 126
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
VL-REMOVE would probably be a good choice.
(vl-remove "hey" '("hey" "this" "is" "a" "bunch" "of" "heys")) ("this" "is" "a" "bunch" "of" "heys") (vl-remove "heys" '("hey" "this" "is" "a" "bunch" "of" "heys")) ("hey" "this" "is" "a" "bunch" "of") |
|
|
|
|
|
#3 |
|
I could stop if I wanted to
Join Date: 2003-05
Posts: 335
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
stig,
Thanks for the response. That worked too well I'm afraid. Let me clarify what I need. I need to delete all the duplicates except one. list would be : ("hey" "this" "is" "hey" "a" "bunch" "hey" "of" "heys") remove all "hey" duplicates: ("hey" "this" "is" "a" "bunch" "of" "heys") Does that clarify it a bit? Thanks,
__________________
Good Blockin' Will DeLoach AutoCad / ADT 2006 |
|
|
|
|
|
#4 |
|
100 Club
Join Date: 2000-12
Posts: 126
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hmmm, it clarifies but also makes it a bit more complex. How is the code supposed to know which item to keep? If the first match is to remain then perhaps something like this will do?
Code:
(defun removeAllButFirst (item lst / n ll)
(setq n (cdr (member item lst)))
(repeat (- (length lst) (length n))
(setq ll (cons (car lst) ll)
lst (cdr lst)))
(append (reverse ll) (vl-remove item n))
)
|
|
|
|
|
|
#5 |
|
I could stop if I wanted to
Join Date: 2003-05
Posts: 335
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I just want it remove all items that are the same except one of them. It doesn't matter which one of them.
Thanks,
__________________
Good Blockin' Will DeLoach AutoCad / ADT 2006 |
|
|
|
|
|
#7 |
|
100 Club
Join Date: 2000-12
Posts: 126
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Ah, no need for order, only removing duplicates:
Code:
(defun removeDups (item lst / ll)
(foreach n lst
(cond ((equal n item)
(and (not (member item ll))
(setq ll (cons n ll))))
(T (setq ll (cons n ll)))))
(reverse ll)
)
Mark, just being curious: which predicate function would you write for VL-REMOVE-IF to remove duplicates? |
|
|
|
|
|
#8 |
|
I could stop if I wanted to
Join Date: 2003-05
Posts: 335
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Thanks stig I'll work that into my code and see how it works.
__________________
Good Blockin' Will DeLoach AutoCad / ADT 2006 |
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Duplicate centroids | panderson.60593 | AutoCAD Map 3D - General | 3 | 2004-06-09 05:40 PM |
| List of problems after my first big work with Revit | overcaffeined | Revit Architecture - General | 12 | 2004-02-04 05:43 AM |