integerPartitions :: [Integer]
integerPartitions =
let
p = go (let kg k = (2*k):k:kg (k+1) in 0:kg 1) [] 0
go :: [Int] -> [[Integer]] -> Int -> [Integer]
go ks a c = s:(if c>0 then go ks b (c-1) else (let (d:kt)=ks in go kt b d))
where
(s,b) = sf a
sf ((a1:t1):(a2:t2):r) = let (t,tr)=sf r in (a1+a2-t,t1:t2:tr)
sf ((a1:t1):_) = if c>0 then (a1,t1:[]) else (a1+1,t1:p:[])
sf _ = if c>0 then (0,[]) else (1,p:[])
in
1:p
main = print $ integerPartitions!!1000