#!/usr/bin/q -c main (val (ARGS!1))

/* Example showing how to run a Q program from the shell, using a "shebang"
   line. See Appendix B.4 in the manual. */

fib N		= A where (A,B) = fibs N;
fibs N		= (B,A+B) where (A,B) = fibs (N-1) if N>0;
		= (0,1) otherwise;

main N:Int	= do (printf "%s\n".str) $ map fib [0..N] || exit 0;
main _		= printf "Usage: %s <number>\n" (ARGS!0) || exit 1
		    otherwise;
