       Re: Lists of all values of a two-variable function

• To: mathgroup at smc.vnet.net
• Subject: [mg64744] Re: Lists of all values of a two-variable function
• From: "J Siehler" <jsiehler at gmail.com>
• Date: Thu, 2 Mar 2006 06:47:29 -0500 (EST)
• References: <du3vcn\$mjd\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```You can get rid of the "list of lists" problem by applying Flatten; and
get rid of the duplicate values problem using Union.  You can just tack
them on to your solution like so:

Table[f[l1[[i]],l2[[j]]],{i,1,Length[l1]},{j,1,Length[l2]}]//Flatten//Union

Or you could do something like this, which is a little shorter and
doesn't introduce superfluous variables:

Apply[f, Outer[List, l1, l2], {2}] // Flatten // Union

(If f happens to returns lists instead of, say, single numbers, you'll
have to be more careful with the flatten statement.)

Or you could do something wacky like this if, I don't know, you're
allergic to Flatten and Union.

ReplaceList[{l1, l2}, {{a1___, a_, a2___}, { b1___, b_, b2___}} :> f[a,
b] /; Not[MemberQ[{a1}, a] ||MemberQ[{b1}, b]]]

```

• Prev by Date: Re: Lists of all values of a two-variable function
• Next by Date: Re: Editing a Palette Notebook
• Previous by thread: Re: Lists of all values of a two-variable function
• Next by thread: Re: Lists of all values of a two-variable function