Re: Define function using lists or tables

• To: mathgroup at smc.vnet.net
• Subject: [mg131415] Re: Define function using lists or tables
• From: "Louis Talman" <talmanl at gmail.com>
• Date: Wed, 3 Jul 2013 22:00:41 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-outx@smc.vnet.net
• Delivered-to: mathgroup-newsendx@smc.vnet.net
• References: <20130703085846.4E7676A7B@smc.vnet.net>

```On Wed, 03 Jul 2013 02:58:46 -0600, Joaquim Nogueira <jen at fct.unl.pt>
wrote:

> Hello. Possibly this is a very simple question.
>
> Is there a way to define a function over a (BIG) list of ordered pairs?
> I mean, suppose that I have a list, created using a Table command or
> something like that, of the form [{a,b},{c,d},etc.] such that, after
> naming it f, say, f = [{a,b},{c,d},etc.], then, afterwards, whenever
> there is a command such that one needs to compute f[a] (or f[c]), the
> program immediately replaces f[a] by b,and f[c] by d?
>
> Thank you.
>

My previous post did almost exactly what you ask for here, with the
difference that it reversed the order of the pairs---because that was what

Call your original list of pairs, say, L, as in  L = {{a, b}, {c, d},...},
and then do

L /. {x_,y_} :> Set[f[x], y];

--Louis A. Talman
Department of Mathematical and Computer Sciences
Metropolitan State University of Denver

<http://rowdy.msudenver.edu/~talmanl>

```

• Prev by Date: Re: Calculating derivate in Mathematica 9 giving wrong result
• Next by Date: Re: Calculating derivate in Mathematica 9 giving wrong
• Previous by thread: Define function using lists or tables
• Next by thread: Re: Define function using lists or tables