On Sunday, 6 March 2022 at 09:13:42 UTC-8 [email protected] wrote:
>
> Beginner's questions, I guess.
>
> Some time ago, Emmanuel Charpentier wrote
>
> var("v", n=2)
>
> which gives
>
> (v0, v1)
>
> Where is this documented? I have been unable to find keywords for var
> other than domain and latex_name. Are there any others?
>
This is documented on SR.var , which is slightly different from the
top-level "var" you are referring to. It looks like the documentation on
the top-level one wasn't updated when the feature was added to SR.var.
Since top-level var just wraps SR.var, it automatically got the feature too.
> Another question:
> I have learnt to write
> x,y,z=var('x,y,z')
>
You can do that, but with the top-level var it's not necessary (this is
exactly where it differs from SR.var) :
it will inject bindings for the created symbols in the current name space.
This is a hack that is convenient for interactive use. In library code, you
must use SR.var instead, in which case you have to write
x,y,z = SR.var('x,y,z')
( with just "SR.var('x,y,z')" you'd create the symbols but you wouldn't
bind them to anything).
Is it possible to do the same for
> v0,v1,v2=var('v', n=3)
> without having to write explicitly the LHS?
>
Yes, that already works. If you use
var('v', n=3)
the names v0,v1,v2 in your current scope will be bound to the newly created
symbols.
There's been discussion about this when it was implemented:
https://trac.sagemath.org/ticket/22813
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-support/316f7db3-2c35-4766-8de1-1dbe14958943n%40googlegroups.com.