MathGroup Archive 1999

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

Search the Archive

RE: Dont Understand

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15884] RE: [mg15857] Dont Understand
  • From: "Jean-Marie THOMAS" <jmthomas at agat.net>
  • Date: Wed, 17 Feb 1999 23:33:35 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

In init the statement s/.{0->-1} does not modify s.
Try this:
s=s/.{0->-1}
or
Partition[s/.{0->-1},n]

Hope this helps,


****************************************
Jean-Marie THOMAS
mailto:jmthomas at agat.net
Conseil et Audit en Ingenierie de Calcul
Strasbourg, France
http://www.agat.net
****************************************

-----Original Message-----
From: Don McKenzie Paul [mailto:phrje at csv.warwick.ac.uk]
To: mathgroup at smc.vnet.net
Subject: [mg15884] [mg15857] Dont Understand



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




  • Prev by Date: Re: PlotVectorField Package (easy question?)
  • Next by Date: Re: Working in Modules
  • Previous by thread: Re: Dont Understand
  • Next by thread: Re: Dont Understand