I use this method on occasion, but it fails in situations like the example given, 
because the contents of the list must be evaluated before the indexed value can be 
looked up.  Thus, if total does equal zero, we still get the divide by zero error.

-Jeff

>Hiya, Kendall.
>
>I've used inline conditionals in Lingo since the early days.
>
>In C, it looked like this:
>
>  return (total == 0) ? 0 : score / total;
>
>In Lingo, you use lists, and it now looks like this:
>
>  return [score / total, 0][(total = 0) + 1]
>
>Christopher Watson
>...
>-----Original Message-----
>From: kendall anderson [mailto:[EMAIL PROTECTED]]
>...
>For example: pretend we want to return a percentage, and we have a score
>and the total. If the total is 0, we want to avoid a divide by zero so
>we might do the following:
>
>return (total=0: 0) ? (a>0: score/total)
>
>...
>
>I'm just looking for a more compact, more 'elegant' solution. I also
>understand this is really a minor point. :)
>...

-----------------------------------------------
Jeff Gomes                     MultiMedia Magic
[EMAIL PROTECTED]       "Giving Life to Ideas"
-----------------------------------------------

[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