Re: array ordered
- Subject: [mg3198] Re: array ordered
- From: espen.haslund at fys.uio.no (Espen Haslund)
- Date: 18 Feb 1996 01:21:19 -0600
- Approved: usenet@wri.com
- Distribution: local
- Newsgroups: wri.mathgroup
- Organization: Universitet i Oslo
- Sender: daemon at wri.com
In article <4fpdl6$f9r at dragonfly.wolfram.com>, wagner at bullwinkle.cs.Colorado.EDU says... ;> ;>I'll give a solution using only the first 3 thicknesses as an example, ;>to save space. The code should work for the longer list as well. ;> ;>thick={0.48,0.71,1.41}; ;> ;>Outer[List, ##]& @@ Table[{0,1}, {Length[thick]}] ;>{{{{0, 0, 0}, {0, 0, 1}}, {{0, 1, 0}, {0, 1, 1}}}, ;> {{{1, 0, 0}, {1, 0, 1}}, {{1, 1, 0}, {1, 1, 1}}}} ;> ;>Flatten[%, Length[thick]-1] ;>{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {0, 1, 1}, ;> {1, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1}} ;> ;>combos = Drop[%, 1] ;>{{0, 0, 1}, {0, 1, 0}, {0, 1, 1}, {1, 0, 0}, ;> {1, 0, 1}, {1, 1, 0}, {1, 1, 1}} ;> ;>{#.thick, #}& /@ combos ;>{{1.41, {0, 0, 1}}, {0.71, {0, 1, 0}}, {2.12, {0, 1, 1}}, {0.48, {1, 0, 0}}, ;> {1.89, {1, 0, 1}}, {1.19, {1, 1, 0}}, {2.6, {1, 1, 1}}} ;> ;>Sort[%] ;>{{0.48, {1, 0, 0}}, {0.71, {0, 1, 0}}, {1.19, {1, 1, 0}}, {1.41, {0, 0, ;1}}, ;> {1.89, {1, 0, 1}}, {2.12, {0, 1, 1}}, {2.6, {1, 1, 1}}} Hi, Your solution is obviously more elegant and general than my attempt. However the combos are perhaps more easily obtained by: combos = Map[IntegerDigits[#,2,Length[thick] ]&,Range[2^Length[thick]-1] ] - Espen