Hi Sam,

LISTx := A A B C D D E
LISTd := $(strip \
                $(foreach v,$(sort $(LISTx)),\
                    $(if $(filter-out 1,$(words $(filter $(v),$(LISTx)))),\
                        $(v))))
$(info My make version=$(MAKE_VERSION))
$(info Original list   => $(LISTx))
$(info Duplicates list => $(LISTd))


This gives out the following:

My make version=4.0
Original list   => A A B C D D E
Duplicates list => A D

Thanks,
Rakesh

> Date: Sun, 27 Jul 2014 11:58:59 +0200
> From: [email protected]
> To: [email protected]
> 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
> [email protected]
> https://lists.gnu.org/mailman/listinfo/help-make
                                          
_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to