local - Maple Help

convert/local

convert an expression to a local name

 Calling Sequence convert(e, 'local')

Parameters

 e - expression; name, string, or symbol

Description

 • An expression e (typically itself a symbol or string) can be converted to a local name using the convert( e, 'local' ) calling sequence. The expression returned is of type symbol, and is guaranteed to be unequal to any name at the same scope in which the call is made. If the expression e is a symbol, then the symbol returned by this conversion has the same external representation as e, but is distinct from e. (See the examples.)
 • Note that, because it is a Maple keyword, the name local must be enclosed in left single quotes, as demonstrated by the examples below.

Examples

 > $\mathrm{convert}\left("a string",'\mathrm{local}'\right)$
 ${\mathrm{a string}}$ (1)
 > $\mathrm{convert}\left(a,'\mathrm{local}'\right)$
 ${a}$ (2)
 > $\mathrm{evalb}\left(=a\right)$
 ${\mathrm{false}}$ (3)
 > $a-$
 ${a}{-}{a}$ (4)
 > $\mathrm{evalb}\left(\mathrm{convert}\left(a,'\mathrm{string}'\right)=\mathrm{convert}\left(\mathrm{convert}\left(a,'\mathrm{local}'\right),'\mathrm{string}'\right)\right)$
 ${\mathrm{true}}$ (5)
 > p := proc()     local t;     evalb( t = convert( t, 'local' ) ) end proc;
 ${p}{≔}{\mathbf{proc}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{t}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{evalb}}{}\left({t}{=}{\mathrm{convert}}{}\left({t}{,}{'}{\mathrm{local}}{'}\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (6)
 > $p\left(\right)$
 ${\mathrm{false}}$ (7)

Even when called on the same argument within the same scope, distinct calls yield distinct names.

 > q := proc()     local    t;     evalb( convert( t, 'local' ) = convert( t, 'local' ) ) end proc:
 > $q\left(\right)$
 ${\mathrm{false}}$ (8)

This is also true for module scopes.

 > m := module()     export e, try1, try2;     local t;     try1 := proc() evalb( e = convert( e, 'local' ) ) end proc;     try2 := proc() evalb( t = convert( t, 'local' ) ) end proc; end module:
 > $m:-\mathrm{try1}\left(\right)$
 ${\mathrm{false}}$ (9)
 > $m:-\mathrm{try2}\left(\right)$
 ${\mathrm{false}}$ (10)

This facility can be used to generate a collection of distinct objects all of which look the same.

 > $S≔\left\{\mathrm{seq}\left(\mathrm{convert}\left(t,'\mathrm{local}'\right),i=1..10\right)\right\}$
 ${S}{≔}\left\{{t}{,}{t}{,}{t}{,}{t}{,}{t}{,}{t}{,}{t}{,}{t}{,}{t}{,}{t}\right\}$ (11)
 > $\mathrm{nops}\left(S\right)$
 ${10}$ (12)
 > $T≔\left\{\mathrm{seq}\left(t,i=1..10\right)\right\}$
 ${T}{≔}\left\{{t}\right\}$ (13)
 > $\mathrm{nops}\left(T\right)$
 ${1}$ (14)