Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

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


  • 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