Re: Lists of all values of a two-variable function
- To: mathgroup at smc.vnet.net
- Subject: [mg64747] Re: [mg64735] Lists of all values of a two-variable function
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 2 Mar 2006 06:47:32 -0500 (EST)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
l1={a,b,c,d}; l2={e,f,g}; Outer[f[#1,#2]&,l1,l2]//Flatten {f(a,e),f(a,f),f(a,g),f(b,e),f(b,f),f(b,g),f(c,e),f(c,f),f(c,g),f(d,e),f(d, f),f(d,g)} l1={a,b,a,d}; l2={e,f,e}; Outer[f[#1,#2]&,l1,l2]//Flatten//Union {f(a,e),f(a,f),f(b,e),f(b,f),f(d,e),f(d,f)} Bob Hanlon > > From: José Carlos Santos <jcsantos at fc.up.pt> To: mathgroup at smc.vnet.net > Subject: [mg64747] [mg64735] Lists of all values of a two-variable function > > Hi all, > > I would like to do this: given a function _f_ in two variables and two > lists l1 and l2, to get the list of all values f[a,b] with _a_ in l1 and > _b_ in l2, with all duplicated values removed. How do I do that? > > The closest thing that I am able to do is: > > Table[f[l1[[i]],l2[[j]]],{i,1,Length[l1]},{j,1,Length[l2]}] > > but, of course: > > 1) what I get is a list of lists; > > 2) I eventually get duplicated values. > > Best regards, > > Jose Carlos Santos > >