[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: associated lists

From: John Graham-Cumming
Subject: Re: associated lists
Date: Thu, 23 Jun 2005 16:30:04 -0400

On Thu, 2005-06-23 at 15:06 -0400, Levent Yilmaz wrote:
> I have a set of associated pairs. And want to execute some command on 
> each pair. Say for example,
> # define present-past tense pairs as follows
> present_tense = go   do  sit call
> past_tense    = went did sat called
> # somehow generate this phony command for each pair
> # using eval (or by other(?) means)
> @echo $(present) today. $(past) yesterday.
> What I want to accomplish in effect is simply using $(foreach ...) but 
> iterate simultaneously through more than one list...

If you grab my GNU Make Standard Library (, then you
can do the following:

    include gmsl

    present_tense = go   do  sit call
    past_tense    = went did sat called

    define-all = $(eval all:: ; @echo $1 today. $2 yesterday)
    $(call pairmap,define-all,$(present_tense),$(past_tense))

This sets up a rule for 'all' that will output the required items.  I
used a :: rule here, but you could do all sorts of things with pairmap.
Here's the output:

    go today. went yesterday
    do today. did yesterday
    sit today. sat yesterday
    call today. called yesterday

John Graham-Cumming

GNU Make Standard Library:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]