Question: Chebyshev Polynomials

I want a procedure that has arguments f(function) N (natural number)  and an array of values a0,...an is what is returned 
So far I have this 
restart
Chebyshev_approx:= (f::procedure , N :: numeric);
local F,n,a;
for n from 0 to N do 
if n=0
then a:=1/Pi*evalf(Int(1/sqrt(1-x^2)*f(x),x=-1..1)
else a:=2/Pi*evalf(Int(1/sqrt(1-x^2)*f(x)*ChebyshevT(n , x),x=-1..1)
fi;
F:=F+a*ChebyshevT( n , x)
od;
F
end;
But im not sure how to get it to be an array and I get an error of 'else' being unexpected.

 

Please Wait...