MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Define function using lists or tables


data = Partition[CharacterRange["a", "z"], 2];


Clear[f]


Set[f[#[[1]]], #[[2]]] & /@ data;


?f



Bob Hanlon




On Wed, Jul 3, 2013 at 4:58 AM, 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.
>
>



  • Prev by Date: Re: Multiple Line coloring and Dashing in ListPlot
  • Next by Date: Re: Calculating derivate in Mathematica 9 giving wrong result
  • Previous by thread: Re: Define function using lists or tables
  • Next by thread: Re: Define function using lists or tables