Re: a tricky List manipulation problem
- To: mathgroup at smc.vnet.net
- Subject: [mg16297] Re: [mg16211] a tricky List manipulation problem
- From: "Wolf, Hartmut" <hwolf at debis.com>
- Date: Sun, 7 Mar 1999 01:05:32 -0500
- Organization: debis Systemhaus
- References: <199903050540.AAA13494@smc.vnet.net.>
- Sender: owner-wri-mathgroup at wolfram.com
Lieber Adalbert, I forget to remark, the procedure I proposed gives the _sorted_ output {tag, x, y} or {tag, y, x}. If this is undesidered, and if you can identify the components in the output, e.g. by data type, just arrange the output. Otherwise tag the input: l1= Select[{#, 1, Random[]}& /@ Range[13], #[[3]] <0.8 &] {{1,1,0.623947},{2,1,0.527556},{3,1,0.208989},{4,1,0.212777},{5,1,0.115255}, {6,1,0.38422},{7,1,0.0553336},{8,1,0.601217},{9,1,0.187998},{10,1,0.281941}, {13,1,0.33703}} l2= Select[{#, 2, Random[]}& /@ Range[13], #[[3]] <0.8 &] {{1,2,0.183391},{2,2,0.102568},{3,2,0.183143},{4,2,0.741642},{6,2,0.231522}, {7,2,0.446785},{8,2,0.433839},{10,2,0.234453},{11,2,0.502992},{13,2,0.45169}} f[{s_, x_}, {t_,_, y_}] /; s===t := {s, x, y} f[_,{s_,_, x_}] := {s, x} FoldList[f, {}, Union[l1,l2]] {{},{1,0.623947},{1,0.623947,0.183391},{2,0.527556},{2,0.527556,0.102568}, {3,0.208989},{3,0.208989,0.183143},{4,0.212777},{4,0.212777,0.741642}, {5,0.115255},{6,0.38422},{6,0.38422,0.231522},{7,0.0553336}, {7,0.0553336,0.446785},{8,0.601217},{8,0.601217,0.433839},{9,0.187998}, {10,0.281941},{10,0.281941,0.234453},{11,0.502992},{13,0.33703}, {13,0.33703,0.45169}} Select[%, Length[#]==3 &] {{1,0.623947,0.183391},{2,0.527556,0.102568},{3,0.208989,0.183143}, {4,0.212777,0.741642},{6,0.38422,0.231522},{7,0.0553336,0.446785}, {8,0.601217,0.433839},{10,0.281941,0.234453},{13,0.33703,0.45169}} your's Hartmut Hartmut Wolf, debis Systemhaus, Darmstadt, Germany ==============[mailto:hwolf at debis.com]============
- References:
- a tricky List manipulation problem
- From: hanssen@zeiss.de
- a tricky List manipulation problem