associated lists

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

associated lists

Levent Yilmaz
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...

Any ideas?

thank you
- L.



_______________________________________________
Help-make mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: associated lists

Paul Smith-20
%% Levent Yilmaz <[hidden email]> writes:

  ly> I have a set of associated pairs. And want to execute some command on
  ly> each pair. Say for example,

  ly> # define present-past tense pairs as follows
  ly> present_tense = go   do  sit call
  ly> past_tense    = went did sat called

  ly> # somehow generate this phony command for each pair
  ly> # using eval (or by other(?) means)
  ly> @echo $(present) today. $(past) yesterday.

  ly> What I want to accomplish in effect is simply using $(foreach ...) but
  ly> iterate simultaneously through more than one list...

I'd check out the pairmap function in the GMSL:

    http://gmsl.sourceforge.net/

--
-------------------------------------------------------------------------------
 Paul D. Smith <[hidden email]>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


_______________________________________________
Help-make mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: associated lists

Ken Smith-2
In reply to this post by Levent Yilmaz
You could use pairmap from the GNU Make Standard Library.  It uses
lisp-like recursion instead of foreach to call a function for each pair
of variables.

http://gmsl.sourceforge.net/

  Ken

On Thu, Jun 23, 2005 at 03:06:52PM -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...
>
> Any ideas?
>
> thank you
> - L.
>
>
>
> _______________________________________________
> Help-make mailing list
> [hidden email]
> http://lists.gnu.org/mailman/listinfo/help-make


_______________________________________________
Help-make mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: associated lists

John Graham-Cumming
In reply to this post by Levent Yilmaz
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 (http://gmsl.sf.net/), 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.
--
John Graham-Cumming

Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/




_______________________________________________
Help-make mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-make