1. abs function
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM> Sep 01, 1998
- 593 views
A cleaner abs function. function absolutevalue(atom i) -- doesn't need to be an integer! atom r r =3D i if i<0 then r =3D -1 * i end if return r end function --Alan =
2. Re: abs function
- Posted by jiri babor <jbabor at PARADISE.NET.NZ> Sep 02, 1998
- 593 views
Alan Tu wrote: >A cleaner abs function. > >function absolutevalue(atom i) -- doesn't need to be an integer! > atom r > r = i > if i<0 then > r = -1 * i > end if > return r >end function Alan, if you want to be serious about cleaning, get rid of the cobwebs: function absolutevalue(atom i) if i<0 then return -i end if return i end function jiri
3. Re: abs function
- Posted by "Graeme." <hmi at POWERUP.COM.AU> Sep 02, 1998
- 574 views
This one works with sequences too. function abs(object x) return x*(x>=0)-x*(x<0) end function Graeme. ----------------------------------------------------
4. Re: abs function
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM> Sep 01, 1998
- 560 views
>Alan, if you want to be serious about cleaning, get rid of the cobwebs: I was saying cleaning in relation not to your function. But I _really, really_ like return (x<0)*(-2)+x Now that _is_ a blast. --Alan =
5. Re: abs function
- Posted by Greg Harris <blackdog at CDC.NET> Sep 01, 1998
- 575 views
Oops Jiri.. you beat me to it.. :) Greg Harris HHS -----Original Message----- From: jiri babor <jbabor at PARADISE.NET.NZ> To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU> Date: Tuesday, September 01, 1998 9:57 AM Subject: Re: abs function >Alan Tu wrote: > > >>A cleaner abs function. >> >>function absolutevalue(atom i) -- doesn't need to be an integer! >> atom r >> r = i >> if i<0 then >> r = -1 * i >> end if >> return r >>end function > > > >Alan, if you want to be serious about cleaning, get rid of the cobwebs: > >function absolutevalue(atom i) > if i<0 then > return -i > end if > return i >end function > >jiri >
6. abs function
- Posted by John Worthington <woodmage at EARTHLINK.NET> Sep 01, 1998
- 586 views
Okay, one last shot at this: function abs(object x) return ((x>=0)*2-1)*x end function This is how I would have done it in C, well, more or less anyways. Laters, ___ _|ohn