Re: problem with Delete[]
- To: mathgroup at smc.vnet.net
- Subject: [mg59007] Re: [mg58917] problem with Delete[]
- From: "Tomas Garza" <tgarza10 at msn.com>
- Date: Tue, 26 Jul 2005 04:03:29 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Delete[v, j] produces a new list containing those elements of v which are
not j. It doesn't actually modify v.
Tomas Garza
Mexico City
>From: Heath Gerhardt <heathgerhardt at hotmail.com>
To: mathgroup at smc.vnet.net
>Subject: [mg59007] [mg58917] problem with Delete[]
>Date: Sat, 23 Jul 2005 05:32:47 -0400 (EDT)
>
>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
>