Re: abs function

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

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

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

Search



Quick Links

User menu

Not signed in.

Misc Menu