Re: Null Return for a Module
- To: mathgroup at smc.vnet.net
- Subject: [mg88707] Re: Null Return for a Module
- From: Helen Read <hpr at together.net>
- Date: Tue, 13 May 2008 07:10:31 -0400 (EDT)
- References: <g0903j$kpp$1@smc.vnet.net>
- Reply-to: HPR <read at math.uvm.edu>
Dave the Funkatron wrote: > Hi all, > > I'm getting strange output and am trying to track down what might be > causing it. I have the following code in my .nb file: > > (* begin code *) > > Test[ ] := Module[ {i, thesum}, > thesum = 0; > For[ i = 1, i <= 3, i++, > thesum = thesum + i > ] > Return[ thesum ] > ] > > Test[ ] > > (* end code *) > > > The output I would expect would be simply > > 6 > > But, I get > > Null Return[6] You are missing a semi-colon. Try this: Test[] := Module[{i, thesum}, thesum = 0; For[i = 1, i <= 3, i++, thesum = thesum + i]; Return[thesum]] -- Helen Read University of Vermont