Function: variable
Section: conversions
C-Name: gpolvar
Prototype: DG
Help: variable({x}): main variable of object x. Gives p for p-adic x, 0
 if no variable can be associated to x. Returns the list of user variables if
 x is omitted.
Description:
 (pol):var:parens:copy        $var:1
 (gen):gen        gpolvar($1)
Doc:
 gives the main variable of the object $x$ (the variable with the highest
 priority used in $x$), and $p$ if $x$ is a $p$-adic number. Return $0$ if
 $x$ has no variable associated to it.
 \bprog
 ? variable(x^2 + y)
 %1 = x
 ? variable(1 + O(5^2))
 %2 = 5
 ? variable([x,y,z,t])
 %3 = x
 ? variable(1)
 %4 = 0
 @eprog\noindent The construction
 \bprog
    if (!variable(x),...)
 @eprog\noindent can be used to test whether a variable is attached to $x$.

 If $x$ is omitted, returns the list of user variables known to the
 interpreter, by order of decreasing priority. (Highest priority is $x$,
 which always come first.)

Variant: However, in library mode, this function should not be used for $x$
 non-\kbd{NULL}, since \tet{gvar} is more appropriate. Instead, for
 $x$ a $p$-adic (type \typ{PADIC}), $p$ is $gel(x,2)$; otherwise, use
 \fun{long}{gvar}{GEN x} which returns the variable number of $x$ if
 it exists, \kbd{NO\_VARIABLE} otherwise, which satisfies the property
 $\kbd{varncmp}(\kbd{NO\_VARIABLE}, v) > 0$ for all valid variable number
 $v$, i.e. it has lower priority than any variable.
