8330 Reputation

19 Badges

11 years, 227 days

MaplePrimes Activity

These are questions asked by nm

What is the correct way, in code, to check if Maple result contains any one of its own global build in symbols such as _Z or _C or any such symbol it uses?

I need to bypass this result. Currently I check explicitly, but I am sure there is a better way. Here is an example


This returns 

Currently I do 

if has(r,_Z1)  or has(r,_Z2) or has(r,_Z3) then

same for _C1, _C2., etc...

But this method is not robust. The problem is that _Z1 is symbol. So I can't check for symbol type in the  result as result could possibly have one of my own symbols there depending on input.

Is there  better way to do this? I am only asking about output of discont here and not any other Maple function. I assume discont uses _Zn only but I am not sure. It could use different symbol? 


r1:=   -1 <= x and x <= 0;
r2:=   0 <= x and x <= 1;

We see that the above can be simplified to one inequality

-1<= x and x<=1

The closest I found to do this is

r1:=-1 <= x and x <= 0;
r2:=0 <= x and x <= 1;
solve(r1 or r2,x);

which gives RealRange(-1, 1) but I'd like to get the form  -1<= x and x<=1 similar to:

I tried convert to piecewise and simplify and few other things. Is there a trick in Maple to simplify/combine/join inequalites like the above? i.e. convert RealRange(-1, 1) to -1<=x and x<=1 

everything is on the real line.

Maple 2023.2

I have this overloaded function foo(). 


foo:= overload(  
        proc(A::integer,$)option overload;
            print("first one, _passed = ", _passed," _npassed = ",_npassed);             
        end proc,

        proc(A::integer,B::integer,$)option overload;
            print("second one  _passed = ", _passed," _npassed = ",_npassed);
        end proc

Which works OK. so I can now do 


But I wanted to indicate that the proc returns say ::integer , and this where I am stuck, I do not know where to add this ::integer

With non-overloaded proc's, this is the syntax

end proc;

but I can't do this with the overloaded function. If I type

foo:= overload(  
        proc(A::integer,$)option overload;
            print("first one, _passed = ", _passed," _npassed = ",_npassed);             
        end proc,

        proc(A::integer,B::integer,$)option overload;
            print("second one  _passed = ", _passed," _npassed = ",_npassed);
        end proc

Maple simply does not like it. typing foo(1) now it just echos the definition back.

And these give syntax errors

foo:= overload(  
        proc(A::integer,$)::integer option overload;
            print("first one, _passed = ", _passed," _npassed = ",_npassed);    
        end proc,

        proc(A::integer,B::integer,$)::integer option overload;
            print("second one  _passed = ", _passed," _npassed = ",_npassed);
        end proc

Tried many other variations and looked at help but see nothing to far.

Can one add ::type to indicate type proc returns with overloaded proc?

Maple 2023.2.1

I wanted to debug some code from worksheet A.  So added DEBUG(); command in the code where I want to start the GUI debugger from, and then run the command from the worksheet. All is working OK. the debugger GUI comes up and I can step in. 

Now I wanted to debug some other code from worksheet B. But without closing the currect debugger which is open and running.

It turned out this is not possible.  When running debugger from worksheet B, it uses the same debugger GUI that was up and running. I think it closed that session automtically also.

So basically using same Maple process, one can't open two debgging sessions at same time? Is there a way around this.

I run each worksheet using its own math engine. So each is separated from each other.

But this is first time I wanted to debug two things at same time, i.e. side by side, thinking I will be able to open two GUI debuggers at same time.

I know ofcourse I can open two separate Maple processes and then I will be able to do this. I think I am allowed to have two Maple's open at same time. Will try that next.

But it will be better if one is able to open two debuggers from same Maple at same time. I do not see why this should not be possible.

Any suggestions if there is a workaround? May be some hidden setting that allows this?

Maple 2023.2.1 on windows 10

I thought I was improving my code by adding ::type to all the _self in my OOP code. As this is one main advantage in programming in Maple, which is being able to attach types to all name and variables. Make code more robust.

But it turned out Maple is not very happy now and gives that drearded error

    Error, static procedure ... refers to non-static local or export ... in surrounding scope

Only place I found that adding ::type_name is to _self is allowed, is on the constructor signature.

But in no other method of the object module. local or export method, it does not matter. 

My question is, why is that?

So I went and removed all those _self::type_name and made it just _self to make Maple happy.

I also noticed this happes regardless of having kernelopts('assertlevel'=2): there or not.  Attached  is the worksheet.

Just tryting to understand the logic, that is all. 

This is using Maple 2023.2.1


`Standard Worksheet Interface, Maple 2023.2, Windows 10, November 24 2023 Build ID 1762575`






  export module person()
   option object;
   local m_name::string;
   local m_age::integer;
   export ModuleCopy::static:=proc(_self::A:-person,proto::A:-person,name::string,age::integer,$)
          _self:-m_age := age;
   end proc;
   export name::static:=proc(_self,$) m_name; end proc;
   export age::static:=proc(_self,$) m_age; end proc;
 end module;

export  module young_person()
   option object;
   local m_person::A:-person;
   export ModuleCopy::static:=proc(_self::A:-young_person,proto::A:-young_person,p::A:-person,$)
          _self:-m_person := p;     
   end proc;
   local process_it::static:=proc(_self,$)
   end proc;

   #to fix the problem, check _self::A... to just _self,  then no error!
   export process_it_from_outside::static:=proc(_self::A:-young_person,$)
   end proc;

end module;

end module;



module person () local m_name::string, m_age::integer; option object; end module



Error, static procedure `young_person:-process_it_from_outside` refers to non-static local or export `young_person:-m_person::A:-person` in surrounding scope


Download why_adding_type_on_self_gives_error.mw

2 3 4 5 6 7 8 Last Page 4 of 161