A lambda function is a kind of anonymous map. For example:
sage: f = lambda x : 2*x
Says "f is the map that sends x to 2*x", and you can check:
sage: f(4)
8
It is anonymous because you can do:
sage: (lambda x : 3*x)(3)
9
Then, you can get the documentation of xmrange_iter
by typing:
sage: xmrange_iter?
This makes your residues the image of a product by a map.
Indeed, the first part of res is the list of lists (to be understood as a product):
sage: res.iter_list
[[-1, 0, 1, 2], [-1, 0, 1, 2]]
and its second part is the map that has to be applied to any element of the product:
sage: res.typ
<function sage.rings.number_field.number_field_ideal.<lambda>>
This second argument is the lambda function you want to understand. Let us play with it:
sage: res.typ((-1,-1))
-a - 1
sage: res.typ((-1,0))
-1
sage: res.typ((0,1))
a
sage: res.typ((0,2))
2*a
sage: res.typ((3,2))
2*a + 3
I am sure you understand what does this lambda function!
Now, the list of residues is just the image of each element of the product $ \{-1, 0, 1, 2\} \times \{-1, 0, 1, 2\} $ by the map (u,v) --> u*1 + v*a
, that is:
sage: list(res)
[-a - 1,
-1,
a - 1,
2*a - 1,
-a,
0,
a,
2*a,
-a + 1,
1,
a + 1,
2*a + 1,
-a + 2,
2,
a + 2,
2*a + 2]
sage: res.cardinality()
16