[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Find duplicates in a list
From: |
Jay Lawrence |
Subject: |
RE: Find duplicates in a list |
Date: |
Sun, 27 Jul 2014 11:02:57 -0400 |
I'm sure one of the cool macro libraries has an elegant solution already,
but here's one I just cooked up
------------ cut here ------------------
# Given a list with duplicates
ORIGINAL := A C B C B D A
# Build a new list in order with no dups
$(foreach V,$(ORIGINAL),$(if $(filter $V,$(NEW)),,$(eval NEW := $(NEW) $V)))
# Or just call sort, but the order may be different
SORTED = $(sort $(ORIGINAL))
result:
@echo ORIGINAL = $(ORIGINAL)
@echo NEW = $(NEW)
@echo SORTED = $(SORTED)
------------------------------
Jay
-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of Sam Ravnborg
Sent: Sunday, July 27, 2014 5:59 AM
To: address@hidden
Subject: Find duplicates in a list
Hi all.
I'm trying to find a way to detect duplicate items in a list without
escaping to a shell.
Consider the following:
list := A B C A D C
In the list above A and C is duplicated.
I would like to find a way so I can find which items are duplicated and
print them out.
The solution should preferably work with gmake 3.81 and even better in make
3.80
Thanks in advance,
Sam
_______________________________________________
Help-make mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-make