MapleUnique - return unique copy of an object in external code
|
Calling Sequence
|
|
MapleUnique(kv, s)
|
|
Parameters
|
|
kv
|
-
|
kernel handle of type MKernelVector
|
s
|
-
|
type ALGEB object
|
|
|
|
|
Description
|
|
•
|
The MapleUnique function processes the Maple expression, s, and returns the unique normalized copy of that expression. For example, if you create the number num = one-billion, and then compute the number val = 2*500-million, an address comparison of num and val does not indicate equality. After calling num = MapleUnique(kv,num);, both num and val point to the same memory.
|
|
|
Examples
|
|
#include "maplec.h"
|
ALGEB M_DECL MyGuessList( MKernelVector kv, ALGEB *args )
|
{
|
static ALGEB mylist = NULL;
|
if( !mylist ) {
|
mylist = MapleListAlloc(kv,2);
|
MapleListAssign(kv,mylist,1,ToMapleInteger(kv,rand()%2));
|
MapleListAssign(kv,mylist,2,ToMapleInteger(kv,rand()%2));
|
mylist = MapleUnique(kv,mylist);
|
MapleGcProtect(kv,mylist);
|
}
|
if( MapleNumArgs(kv,(ALGEB)args) > 0 && args[1] == mylist ) {
|
return( ToMapleBoolean(kv,TRUE) );
|
}
|
return( ToMapleBoolean(kv,FALSE) );
|
}
|
|
|
Execute the external function from Maple.
>
|
|
>
|
|
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
|
|