MathGroup Archive 2001

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

Search the Archive

Re: List Manipulation


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


  • Prev by Date: Re: Re: Re: Limit question
  • Next by Date: Re: List Manipulation
  • Previous by thread: List Manipulation
  • Next by thread: Re: List Manipulation