abs function...

new topic     » topic index » view thread      » older message » newer message

Howdy,

I know a while ago there was much discussion on the
best code for an abs function. I'm not sure what the
final result was, but I came up with a one-liner which
i dont think I'd seen before. Hope it's some use to
somebody. It can handle atoms, sequences and nested
sequences.

-- abs function
function abs( object x )
    return sqrt( x * x )
end function

Logic: fairly simple. The square of any number is
positive.

Hope it's some help,

- Mike Fowler.
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu