Ask Your Question
1

Dot-angle syntax

asked 2015-04-28 02:52:04 -0500

Oderyn gravatar image

Can somebody give me a hint where this kind of syntax

S.<x> = NumberField(x^2-5)

is defined? I mean the S.<x>. It's (relatively) clear from the examples what it does, but I've never seen an a real explanation in the manual.

Thank you.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-04-28 14:20:13 -0500

eric_g gravatar image

Hi,

The syntax S.<x>=..., which is not standard Python, is actually interpreted by the Sage preparser. You can find how it is transformed to standard Python by means of the preparse command, with "S.<x>=..." as an argument (don't forget the quotes):

preparse("S.<x> = NumberField(x^2-5)")

The output is

"S = NumberField(x**Integer(2)-Integer(5), names=('x',)); (x,) = S._first_ngens(1)"

As you can see, it is a short-cut ("syntactic sugar") for combining two definitions into a single instruction: the definition of S and that of x, as a generator of S.

This is documented in Sage reference manual: look for sage.repl.preparse.preparse_generators in this page

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

1 follower

Stats

Asked: 2015-04-28 02:52:04 -0500

Seen: 68 times

Last updated: Apr 28 '15