Re: problem with Delete[]
- To: mathgroup at smc.vnet.net
- Subject: [mg58925] Re: [mg58917] problem with Delete[]
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 24 Jul 2005 01:21:47 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
Delete doesn't change v v={a,b,c,d,e}; Delete[v,3] {a,b,d,e} v {a,b,c,d,e} If you want v to change, use v=Delete[v,3] {a,b,d,e} v {a,b,d,e} Bob Hanlon > > From: Heath Gerhardt <heathgerhardt at hotmail.com> To: mathgroup at smc.vnet.net > Date: 2005/07/23 Sat AM 05:32:47 EDT > Subject: [mg58925] [mg58917] problem with Delete[] > > Hello, > > Delete[] is not removing elements of v in the following function, could > anyone tell me why? > > Rn[N_, p_] := Module[{A, v, c, q, i, j}, > A = Table[0, {i, 1, N}, {j, 1, N}]; > v = Table[i, {i, 2, N}]; > c = 1; > For[i = 1, i < N, i++, > j = Random[Integer, {1, Dimensions[v][[1]]}]; > A[[c, v[[j]]]] = 1; > A[[v[[j]], c]] = 1; > q = Random[]; > If[q > p, c = v[[j]]]; > Delete[v, j]; > ]; > A > ] > > thanks in advance, > Heath > >