Generate the list [1, 0, -1, 0, 1, 0, -1, 0, ...] In the spirit of a question on math.se: given an integer n, return the integer in position n of the sequence [1, 0, -1, 0, 1, 0, -1, 0, ...]. Assume n &gt;= 0.

Rules:


You may only use the operations -x, x+y, x-y, x*y, x/y, and xy, whatever their representations are in the language you choose.
Your function must be called a.
Your function must run in constant time for all n.


Example:

a=lambda n:((-1)**(n*n-n)//2)+(-1)**(n*n+n)//2))//2


Non-example (uses list subscripting operation and modulo operator):

a=lambda n:[1,0,-1,0][n%4]


Non-example (uses cos operation):

from math import *;a=lambda n:int(cos(n*pi/2))


Non-example (does not run in constant time and uses if operation):

a=lambda n:-a(n-2) if n&gt;1 else 0 if n&gt;0 else 1


Clarifications: Both integer and float division are allowed. Your solution may return either an integer or a float (or complex number, I suppose, since some answers already used it). If your solution returns a float: your solution should, if it were to theoretically be carried out to infinite precision, give the exact answer.
Ruby, 26 characters
a=-&gt;n{1-(k=n-n/4*4)+k/3*2}

Example:
&gt; p (0..10).map{|n| a[n]}
[1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]

Note: This solution assumes that integer division / is an allowed operation.