Re: List Manipulation
- To: mathgroup at smc.vnet.net
- Subject: [mg31548] Re: List Manipulation
- From: awacs7 at home.com (Aram Schiffman)
- Date: Sat, 10 Nov 2001 01:19:36 -0500 (EST)
- References: <9sgeqm$93v$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Jonathan,
Here's one way:
ClearAll[toOne]
toOne[x_] := If[Head[x] === List, x, If[x === 0 || x === 0., 0, 1]]
alist = {{A, {0, 0, 0, a}}, {B, {b, 0, 0, d}}, {C, {-a, -b, 0, 0}},
{D, {c, 0,
0, -c}}};
unwound = Thread[alist];
list01 = {unwound[[1]], MapAll[toOne, unwound[[2]]]};
Thread[list01]
That gives this for output:
Out[12]=
{{A, {0, 0, 0, 1}}, {B, {1, 0, 0, 1}}, {C, {1, 1, 0, 0}}, {D, {1, 0,
0, 1}}}
Good luck,
Aram