MathGroup Archive 2007

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

Search the Archive

Re: Passing a list as seperate parameters?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73235] Re: Passing a list as seperate parameters?
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Thu, 8 Feb 2007 03:41:21 -0500 (EST)
  • References: <eqc71p$qs7$1@smc.vnet.net>

On Feb 7, 11:44 am, "Azumanga" <4zuma... at gmail.com> wrote:
> I have a recuring problem in using mathematica, which I'm sure there
> must be a simple fix for, but I've looked through the manual and can't
> find it.
>
> As an example, I build up the list { {a,b},{c,d} }, and I want to find
> the union of it's elements.
>
> At first glance, I want Union. However, Union wants it's input as
> Union[{a,b},{c,d}], Union[{{a,b},{c,d}}] doesn't do anything.
>
> In general I get around this by fold, but it seems there should be a
> simpler method?

I don't understand what you ask.

Union works in the desirable way.

Compare

Table[{Random[Integer, {0, 5}], Random[Integer, {0, 5}]}, {20}]
{{5, 5}, {3, 4}, {5, 0}, {5, 3}, {2, 5}, {1, 0}, {0, 5}, {3, 4}, {2,
0}, {5, 0}, {1, 2}, {1, 0}, {5, 4}, {1, 2}, {1, 3}, {1, 3},
  {4, 0}, {5, 1}, {1, 2}, {3, 0}}

Union[%]
{{0, 5}, {1, 0}, {1, 2}, {1, 3}, {2, 0}, {2, 5}, {3, 0}, {3, 4}, {4,
0}, {5, 0}, {5, 1}, {5, 3}, {5, 4}, {5, 5}}

with

Union[{5, 5}, {3, 4}, {5, 0}, {5, 3}, {2, 5}, {1, 0}, {0, 5}, {3, 4},
{2, 0}, {5, 0}, {1, 2}, {1, 0}, {5, 4}, {1, 2}, {1, 3},
  {1, 3}, {4, 0}, {5, 1}, {1, 2}, {3, 0}]
{0, 1, 2, 3, 4, 5}

Best Regards



  • Prev by Date: Re: BarChart and Ticks problem.
  • Next by Date: (in)dependent variables in DSolve: need explanation.
  • Previous by thread: Re: Passing a list as seperate parameters?
  • Next by thread: 2D-graph with TextListPlot command