Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Best practices of coding using Mathematica?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98622] Re: [mg98591] Best practices of coding using Mathematica?
  • From: "David Park" <djmpark at comcast.net>
  • Date: Tue, 14 Apr 2009 06:18:59 -0400 (EDT)
  • References: <13645178.1239608870774.JavaMail.root@n11>

1) Go to Help, Documentation Center, Core Language, Functional Programming
and try to become familiar with these commands. If you're used to procedural
programming, a few of the functional commands may take a while to get used
to but just keep 'pushing the envelope'.

2) Localize variable values. Don't write code like:

x = 3;

f = x^2 + Sqrt[y]

Plot[f, {y, 0, 5}]

Instead write:

f[x_, y_] := x^2 + Sqrt[y]

Plot[f[3, y], {y, 0, 5}]


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  


From: meitnik [mailto:meitnik at gmail.com] 

Hi,

As a new user of Mathematica, where would I find coding style info towards
good coding. I don't  want to get into bad habits of coding. Any docs
anyone can recommend? Thanks





  • Prev by Date: Re: converting a list element into a number?
  • Next by Date: Re: Change in NSolve algorithm
  • Previous by thread: Re: Best practices of coding using Mathematica?
  • Next by thread: converting a list element into a number?