map fun [0 .. ]
where
fun n
| even n = n `quot` 2
| otherwise = (1 - n) `quot` 2
There aren't any standard implementations to list all points in ℤk. Not even for k == 1
, really. But with any enumeration of ℤ and a cartesian product of two lists that outputs any pair at a finite index even if the lists are infinite (some possible implementations here), you can roll your own.
integers :: [Integer]
integers = -- whatever is your favourite implementation
-- get all pairs at finite index, even for infinite input lists
--
cartesian :: [a] -> [b] -> [(a,b)]
cartesian xs ys = ???
-- enumDim k enumerates the points in ℤ^k, to avoid type problems, the points
-- are represented as lists of coordinates, not tuples
enumDim :: Int -> [[Integer]]
enumDim k
| k < 0 = error "Can't handle negative dimensions"
| k == 0 = [[]]
| otherwise = map (uncurry (:)) $ cartesian integers (enumDim (k-1))
-- alternative:
{-
| k == 1 = map return integers
| otherwise = map (uncurry (++)) $ cartesian (enumDim h) (enumDim (k-h))
where
h = k `quot` 2
-}