Re: Working in Modules
- To: mathgroup at smc.vnet.net
- Subject: [mg15924] Re: Working in Modules
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 17 Feb 1999 23:33:57 -0500
- Organization: Universitaet Leipzig
- References: <7a2c0d$1ul@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Don, you must assign a result to your replacement. init[n_Integer]:=Module[ {s=Table[Random[Integer],{n n}]}, s=s/.{0->-1}; Partition[s,n] ] will work. The second works because the return value of a Module[] is the last evaluated expression. Hope that helps Jens Dr D McK Paul wrote: > > This is my third attempt to post this question. No idea why it doesnt > work. 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} > ]