Re: number not fitting in
- To: mathgroup at smc.vnet.net
- Subject: [mg71569] Re: [mg71546] number not fitting in
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 23 Nov 2006 05:41:40 -0500 (EST)
- Reply-to: hanlonr at cox.net
The line you provided appears to work fine so I am not sure what you are trying to do.
lyst=CharacterRange["a","z"];
Module[{len=Length[lyst]},
lyst[[Random[Integer,{1,len}]]]=
Random[Integer,len+{1,100}]];
lyst
{a,b,c,d,e,78,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}
You could also use ReplacePart
lyst=CharacterRange["a","z"];
Module[{len=Length[lyst]},
ReplacePart[lyst,
Random[Integer,len+{1,100}],
Random[Integer,{1,len}]]]
{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,30,s,t,u,v,w,x,y,z}
Bob Hanlon
---- "JGBoone at gmail.com" <JGBoone at gmail.com> wrote:
> First let me say that i am new to this mathematica and programming
> business. I am programming a random speciation. I have a list, lyst,
> that is a certain range. I want to replace, at random, one part of lyst
> with something that is not in the original list, speciation. When I
> table this, it puts the speciation outside the list and inside the
> list. Can anyone help me? here's the line that seems to be giving me
> trouble.
>
> lyst[[Random[Integer, {1, Length[lyst]}]]] = Random[Integer,
> {Length[lyst]+ 1,Length[lyst] + 100}]
>
>
> thanks
>