-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Stephan Beal wrote: > i've created a function which removes duplicates from a list while > keeping their relative order untouched (code is below). While it > appears to work fine, i'm not at all happy with the temp var it uses > ($(remove-dupes-holder)). Is there anyone out there who would care to > take a crack at improving this function, so that it doesn't need the > extra variable (or any improvement, for that matter)? > > # $(call remove-dupes,list) > # Returns a string equal to list with duplicate entries > # removed. It does not sort the list. > remove-dupes-holder := > remove-dupes-impl = $(if $(filter $(1),$(remove-dupes-holder)),,\ > $(eval remove-dupes-holder+=$1)) > remove-dupes = $(strip \ > $(eval remove-dupes-holder:=)\ > $(foreach ENTRY,\ > $(if $1,$1,),\ > $(call remove-dupes-impl,$(ENTRY)))\ > $(remove-dupes-holder))
You could always use the function 'uniq' which is in my GMSL. Here's the definition: uniq = $(if $1,$(call uniq,$(call chop,$1)) $(if $(filter $(call last,$1),$(call chop,$1)),,$(call last,$1))) John. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGg7dyLphrp73n/hARAqsxAKDnwu/NK4g3zpiS3cbLJC8k0r/1VQCgk6aW YvCkcfP/zu/ur7PdMMtuMx0= =h0a/ -----END PGP SIGNATURE----- _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
