convert/local - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Conversion : convert/local

convert/local

convert an expression to a local name

 

Calling Sequence

Parameters

Description

Examples

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

converta string,'`local`'

a string

(1)

converta,'`local`'

a

(2)

evalb=a

false

(3)

a

aa

(4)

evalbconverta,'string'=convertconverta,'`local`','string'

true

(5)

p := proc()
    local t;
    evalb( t = convert( t, '`local`' ) )
end proc;

pproclocalt;evalbt=convertt,'local'end proc

(6)

p

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

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:-try1

false

(9)

m:-try2

false

(10)

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

Sseqconvertt,'`local`',i=1..10

St,t,t,t,t,t,t,t,t,t

(11)

nopsS

10

(12)

Tseqt,i=1..10

Tt

(13)

nopsT

1

(14)

See Also

convert

keyword

name

procedure

type/name

type/symbol

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam