>You might use a single line expression like this one:
>return (score / (total * (total > 0) + (total = 0))) - score * (total = 0)


What about this:

on f score,total
  return score * (total <> 0) / (total + (total = 0))
end

-- Welcome to Director --
put f(4.0, 5)
-- 0.8000

put f(4.0, 0)
-- 0.0000

put f(0, 5.0)
-- 0.0000

put f(0.0, 0)
-- 0.0000

It's a bit less convoluted. If total=0 it becomes score*0 / (0+1) = 0, otherwise
it becomes score*1 / (total + 0).

Fergus

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to