Ask Your Question

what meanings about "xmrange_iter([[0, 1], [0, 1]], <function <lambda> at 0xb94ab1c>)"

asked 2014-01-08 03:52:37 +0200

cjsh gravatar image
K.<a> = NumberField(x^2 +26);K;I = K.ideal(2);show(I)
res =  I.residues(); res;show(list(res));res =  (2*I).residues(); res;show(list(res))

***xmrange_iter([[0, 1], [0, 1]], <function <lambda> at

***xmrange_iter([[-1, 0, 1, 2], [-1, 0, 1, 2]], <function <lambda>
at 0xb94abfc>)***

I know [0, 1] is a coordinates but what meanings about "lambda","0xb94abfc"?
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2014-01-08 10:52:12 +0200

tmonteil gravatar image

updated 2014-01-08 10:56:46 +0200

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)

It is anonymous because you can do:

sage: (lambda x : 3*x)(3)

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))
sage: res.typ((0,1))
sage: res.typ((0,2))
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,
 a - 1,
 2*a - 1,
 -a + 1,
 a + 1,
 2*a + 1,
 -a + 2,
 a + 2,
 2*a + 2]

sage: res.cardinality()
edit flag offensive delete link more

Comments doesn't apply here, apparently :)

kcrisman gravatar imagekcrisman ( 2014-01-08 10:57:14 +0200 )edit

Hehe, the same just appeared the other way with [this question](, so i dramatically shortened my answer while posting.

tmonteil gravatar imagetmonteil ( 2014-01-08 11:17:23 +0200 )edit

answered 2014-01-08 10:56:12 +0200

kcrisman gravatar image
sage: K.<a> = NumberField(x^2 +26);K;I = K.ideal(2)
Number Field in a with defining polynomial x^2 + 26
sage: I
Fractional ideal (2)
sage: res =  I.residues()
sage: res
xmrange_iter([[0, 1], [0, 1]], <function <lambda> at 0x111a0cc08>)
sage: type(res)
<type 'instance'>

What you see from this is that I.residues, as stated in its documentation,

   Returns a iterator through a complete list of residues modulo this
   integral ideal.

An iterator is basically something you can iterate through in a loop or list. If you just do

sage: list(res)
[0, a, 1, a + 1]

you get what you expect, I think. But when you just put res then it tells you what res it, instead of looping through it or listing it - and it's an xmrange_iter Sage object, complete with a Cartesian product and a function applied to them which is the type. See

sage: xmrange_iter?

for more details. It is not really something worry about, though; just make your lists as normal.

edit flag offensive delete link more

answered 2014-01-10 03:24:50 +0200

cjsh gravatar image

thank you very much!

lambda and xmrange_iter is very good function!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-01-08 03:52:37 +0200

Seen: 381 times

Last updated: Jan 10 '14