MathGroup Archive 2002

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

Search the Archive

Some list questions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37132] Some list questions
  • From: "flip" <flip_alpha at safebunch.com>
  • Date: Sat, 12 Oct 2002 05:05:00 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello (sorry for the long post),

I have two seperate list questions that I was hoping to get help with.

Question 1.

 I have a variable length list similar to that generated by FactorInteger,
that is {number, exponent} pairs.  An example follows.

lista =  {{2,3},{3,1},{5,1}}  ... this is the number 2^3 * 3^1 * 5^1

I want to generate a list of "all" the products of numbers from this list.

I can tell that I get a total (3+1)*(1+1)*(1+1) = 4*2*2 = 16, products and I
want a list showing all of those.

These would be:

2^3 can generate {2^0, 2^1, 2^2, 2^3} = {1, 2, 4 ,8}
3^1 can generate {3^0,  3^1} = {3} ... we dont care about the duplicate "1"
5^1 can generate {5^0, 5^1} = {5} ... we dont care about the duplicate "1"

Hence the 4*2*2 = 16 (the product of one more of the exponents) above.

Next we should get 16 products (from these lists), namely (I left them as
products below to show what I am after):

{1,  2,  4,  8,  1*3,  2*3,  4*3,  8*3, 1*5, 2 * 5, 4* 5, 8* 5, 1*3*5,
2*3*5,  4*3*5,  8*3*5}

If the list were lista = {{2,4}, {3,2}, {5, 3},{7^5}}, we would have
(4+1)(2+1)(3+1)(5+1) = 360 products, for example and the return values
should be a single list showing all of those.

Question 2.

I have two lists and want to generate two new lists from them.  These two
lists are {number, exponent} pairs.

In the first list, I want the "minimum intersection" of {number, exponent}
pairs.

In the second list, I want the "maximum union" of {number, exponent} pairs.

Let me show an example:

Input:

list1 = {{2, 3}, {3, 4}, {5, 6}, {7, 2}, {17, 5}}

list2 = {{2, 5}, {3, 2}, {5, 1}, {7, 3}}

Output:

minint = {{2, 3}, {3, 2}, {5, 1}, {7, 2}}

Note: In this example we only kept those pairs where the intersection of the
number exists and also keep the min power of those.

maxint =  {{2, 5}, {3, 4}, {5, 6}, {7, 3}, {17, 5}}

Note: In this example we kept the union of lists and also keep the max power
of each.

Thank you so much to this newsgroup for being so helpful.

Flip

Note: remove the "_alpha" from the email given to email me.





  • Prev by Date: 5th Degree Polynomials
  • Next by Date: Re: Function vs. Procedure
  • Previous by thread: 5th Degree Polynomials
  • Next by thread: Re: Some list questions