Re: mathematica newbie trouble
- To: mathgroup at smc.vnet.net
- Subject: [mg99309] Re: mathematica newbie trouble
- From: Bob F <deepyogurt at gmail.com>
- Date: Sat, 2 May 2009 06:00:36 -0400 (EDT)
- References: <gtegon$1vu$1@smc.vnet.net>
On May 1, 3:52 am, Guapo <yangsh... at gmail.com> wrote: > i wrote the following mathematica code: > > s := (a + b + c)/2; > k[a_, b_, c_] := Sqrt[s (s - a) (s - b) (s - c)]; > k[3, 4, 5] > k[5, 9, 12] > > when run it, i can't get the write answer. but i change setDelayed(:=) > to set(=), everything works ok > > s = (a + b + c)/2; > k[a_, b_, c_] = Sqrt[s (s - a) (s - b) (s - c)]; > k[3, 4, 5] > k[5, 9, 12] > > i did a google search for the difference of set and setDelayed, > however, i still can't understand it for the upper described problem, > could anyone explain it? great thanks. You could change this to something like: k[a_, b_, c_] := { s = (a + b + c)/2; Sqrt[s (s - a) (s - b) (s - c)] } k[3, 4, 5] k[5, 9, 12] -Bob