Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Working in Modules

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15923] Re: Working in Modules
  • From: "Roger Wilson" <roger.wilson at nomura.co.uk>
  • Date: Wed, 17 Feb 1999 23:33:56 -0500
  • Organization: Nomura International PLC
  • References: <7a2c0d$1ul@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Init doesn't return the list you think it should because you haven't reset
the value of s.  You've done substitution s /. {0->-1} but this doesn't
change the value of s it just returns a list that you haven't put anywhere
and then returned Partition[s,n].

You need to do s=s/.{0->-1}; inside init 1 instead of just s/.{0->-1};

Roger


Dr D McK Paul wrote in message <7a2c0d$1ul at smc.vnet.net>...
>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}
>                    ]
>
>
>--
>





  • Prev by Date: Re: Coupled Diff Eqn
  • Next by Date: Re: Coupled Diff Eqn
  • Previous by thread: Re: Working in Modules
  • Next by thread: Re: Working in Modules