Re: Dont Understand
- To: mathgroup at smc.vnet.net
- Subject: [mg15920] Re: [mg15857] Dont Understand
- From: Jurgen Tischer <jtischer at col2.telecom.com.co>
- Date: Wed, 17 Feb 1999 23:33:55 -0500
- Organization: Universidad del Valle
- References: <199902122340.SAA02343@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I'm confused too, but only about your name. Is it Don or Paul? Your line s/.{0->-1} didn't change s, so the last command of init, which is what a Module gives back, returned the Partition of the original s. Init1 has as its last command s/.{0->-1}, so this is what you got. Jurgen Karl Anton Tischer Don McKenzie Paul wrote: > > I'm not an expert in Mathematica and would appreciate comments on why > init1 returns a list with all zeros replaced by -1, but init does not. > Its probably very simple but its confused me. > > Don > > init[n_Integer]:=Module[ > {s=Table[Random[Integer],{n n}]}, > s/.{0->-1}; > Partition[s,n] > ] > > init1[n_Integer]:=Module[ > {s=Table[Random[Integer],{n n}]}, > s/.{0->-1} > ] > > -- > > Prof. Don McKenzie Paul tel. (1203) 523603 Department of > Physics fax. (1203) 692016 University of Warwick > email phrje at csv.warwick.ac.uk COVENTRY CV4 7AL > UK
- References:
- Dont Understand
- From: Don McKenzie Paul <phrje@csv.warwick.ac.uk>
- Dont Understand