1. recursive arccos function...

Hi all!

following codes are the recursive version of "arccos" function
which accept both the atom value, and the sequence of arbitrary structure.
However, since it is my first trial of "recursive programming",
i'm not sure if it has no leaks for all the conditions.

Dear respectable programming gurus in this list, please check my
codes and tell me whether this codes are correct or not!

Bye -- from Lee, wooseob
-------------------- codes start here ---------------------------------
constant Pi=arctan(1)*4
function arccos(object x)
    sequence s
    if atom(x) then
        if x=1 then return 0
        elsif x=-1 then return Pi
        else return -arctan(x/sqrt(-x*x+1)) + Pi/2
        end if
    else
        s={}
        for i=1 to length(x) do s=s&{arccos(x[i])} end for
        return s
    end if
end function
---- test program
sequence s
s={0.1,0.2,{{0.1,0.2}},0.3,{0.3}}
?arccos(s)
------------------- codes end here ------------------------------------

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu