Re: Fuction definition

*To*: mathgroup at smc.vnet.net*Subject*: [mg73708] Re: Fuction definition*From*: Helen Read <hpr at together.net>*Date*: Sun, 25 Feb 2007 04:35:49 -0500 (EST)*References*: <erme23$i63$1@smc.vnet.net> <eroqbp$9hd$1@smc.vnet.net>

Jean-Marc Gulliet wrote: > bar at ANTYSPAM.ap.krakow.pl wrote: > >>It is safely to use "=" in function definition ? > > The usual way for defining a function is to use SetDelayed, not Set. > >>I'm not sure is this good idea to use '=' ? > > Short answer: no, not for defining a function. As Bill Rowe pointed out in another reply to this thread, there are times when set is better than set delayed (for example, if you define a function as an integral, it might be better to evaluate the integral once, instead of every time the function is called). I personally use set most of the time when I define functions, unless there is a real reason for using set delayed. For purposes of teaching, I find students benefit from using set in their function definitions, so that they see output when they make the definition. This often allows them to immediately catch the kinds of mistakes that students tend to make (e.g., Sin(x)/x rather than Sin[x]/x, or 2/x+1 instead of 2/(x+1)). With set they can see right away that something is amiss when they look at the output. I do teach them about set delayed because there are times when they need it, but for most of their daily work set works just fine. -- Helen Read University of Vermont