On Sun, Jul 27, 2014 at 11:02:57AM -0400, Jay Lawrence wrote:
> 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)
>
> ------------------------------
Thanks.
In the meantime I came up with this:
------
FOO := A A B C D D E
DUPS := $(foreach v, $(FOO), $(if $(subst 1,,$(words $(filter $v, $(FOO)))),$v))
$(info DUPS=$(sort(DUPS)))
-----
This find each entry that occur more than once and prints out the entries that
occur more than once.
This matches better what I need than the proposal you came up with.
But if there is a simpler / smarter way I am all ears.
> I'm sure one of the cool macro libraries has an elegant solution already,
But then when you need this - suddenly they do not appear when you
ask google for help.
Sam
_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make