I'd probably white a separate function for the sum Fourier series, just for the case if I have to calculate another series.<br>Something like this:<br><br>fourier(A, B, X) -><br> fourier(A, B, X, 1, 0).<br><br>
fourier([], [], _, _, Acc) -><br> Acc;<br><br>fourier([H1|T1], [H2|T2], X, Pos, Acc) -><br> Arg = Pos * X,<br> fourier(T1, T2, X, Pos+1, Acc + H1 * math:cos(Arg) + H2 * math:sin(Arg)).<br> <br>--yg<br><br>
<div><span class="gmail_quote">2008/4/11, Jilani Khaldi <<a href="mailto:jilani@cheapnet.it">jilani@cheapnet.it</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi All,<br> I am translating this Pascal code:<br> <br> t := 2*3.14159*((JD - 1) / 365.0);<br> declination := (0.322003 - 22.971 * cos(t)<br> - 0.357898 * cos(2*t)<br> - 0.14398 * cos(3*t)<br>
+ 3.94638 * sin(t)<br> + 0.019334 * sin(2*t)<br> + 0.05928 * sin(3*t));<br> <br> // Check it<br> if (declination > 89.99) then declination := 89.99;<br>
if (declination < -89.99) then declination := -89.99;<br> <br> to Erlang:<br> <br> T1 = 2*3.14159*((JD - 1) / 365.0),<br> Declination1 = (0.322003-22.971*cos(T1)<br> -0.357898*cos(2*T1)<br> -0.14398*cos(3*T1)<br>
+3.94638*sin(T1)<br> +0.019334*sin(2*T1)<br> +0.05928*sin(3*T1)),<br> <br> % Check it<br> if (Declination1 > 89.99) -><br> Declination2 = 89.99;<br> true -><br> Declination2 = Declination1<br>
end,<br> if (Declination1 < -89.99) -><br> Declination2 = -89.99;<br> true -><br> Declination2 = Declination1<br> end,<br> Declination2.<br> <br> The Erlang code works but I think there is at least one way to write it<br>
better.<br> Thank you!<br> <br>--<br> ***<br> Jilani KHALDI<br> <a href="http://www.dotpas.org">http://www.dotpas.org</a><br> _______________________________________________<br> erlang-questions mailing list<br> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br> </blockquote></div><br>