nm

11353 Reputation

20 Badges

13 years, 20 days

MaplePrimes Activity


These are questions asked by nm

I do not understand why the following is not working. I have a package which has a module inside it. The module is exported by the package.

Inside that module, there is a proc, which is also exported by the module.

So why can't one call the proc from outside the package? What Am I doing wrong? and how to correct it? I'd like to be able to call the proc directly. 

A:=module()
  option package;
  export B;
  B := module()
      export foo;

      foo:=proc()
           print("in foo");
      end proc;

  end module;
end module;   

Now when typing (A::B):-foo() Maple is not happy and says Error, module does not export `foo`

I tried different syntax from the above, but can't get it to work. For example A::B:-foo() gives Error, `B` does not evaluate to a module

 

Maple 2019.1

When making a proc that accepts positional and keyword based arguments, Maple allows the caller to put the keyword arguments before or after the positional arguments, or in between.

Is there a way to force the keyword arguments (if they are used) to only be placed after the (required) positional arguments during the call? 

An example will make it more clear. Given this proc

foo := proc(a::integer, b::integer, {c::integer:= 1, d::integer:= 1},$)
    print("a=",a," b=",b," c=",c," d=",d);
end proc:

It can be called as any one of these cases

foo(1,2);                                #case 1                                             
foo(1, 2,'c' = 1, 'd' = 2);              #case 2
foo('c' = 1, 1, 'd' = 2, 2);             #case 3
foo('c' = 1, 1, 2);                      #case 4
foo(1, 'c'=1, 2);                        #case 5
#more combinations possible

Is it possible to change how proc is defined, so that Maple will accept case1, and case 2 only in the above when the call is made and give an error otherwise?

i.e. only allow keyword arguments after all positional arguments.  I read https://www.maplesoft.com/support/help/Maple/view.aspx?path=argument_processing  and it says

After all arguments matching keyword parameters have been processed, matching of required positional and optional or expected ordered parameters is carried out

So from above, it looks like what I am asking for is not really possible. But I thought to ask, in case there is some way.

I find ability to put keyword arguments in the call anywhere and in-between required positional arguments confusing that is all.

Maple 2019.1

Is there a command or method in Maple to list all initially protected names?

This page https://www.maplesoft.com/support/help/Maple/view.aspx?path=UndocumentedNames list undocumented protected names, and this page https://www.maplesoft.com/support/help/Maple/view.aspx?path=initialconstants  lists initially known names, which I assume are all protected.

But what about a list of all protected names? sin,cos, eval, uneval, etc.. any name that can't be assigned to. In my search so far, I could not find how to find these names. There are 100's of such names. Can one get them all in a list to look at?

Using Maple 2019.1

Could someone confirm if this is a problem in this sample application?

In 2019, in the folder 

    C:\Program Files\Maple 2019\samples\ProgrammingGuide\RandomnessTests

There is sample application. Opening the main module file RandomnessTests.mpl  and scrolling down a little bit to the include statements show

$include "WaldWolfowitz.mm"
$include "BitFrequency.mm"
$include "SequenceFrequency.mm"
$include "Compressibility.mm"
$include "BinaryRank.mm"
$include "Entropy.mm"

$include "Data.mm"
$include "Visualization.mm"

However, in the same folder, there is no Data.mm file. There is only Data.mpl file.

So how could this sample application work?  

This sample app have more problems. The file Visualization.mm  say

Data := module()
option package;
...

And the file Data.mpl has

Data := module()
....

This is all so confusing. Seems someone made some typos and not tested this app? Why put a sample application which makes learning packages in Maple more confusing?

ps. I did not yet try to figure how to locad it and run it myself, I was just browsing it.

 

 

I spend some time searching and reading help. But not able to find if this is possible.

I use worksheet only (i.e. not 2D document). I have my display set as

 

I'd like diff(y(x),x) to display as y'(x) in output.

I know I can do this 

PDEtools:-declare(y(x), prime = x);

And that will make diff(y(x),x) display as y'  but I want y'(x). And the same for diff(y(x),x$2) to display as y''(x). And to be clear, y(x) will still display as y(x).  I am mainly interested in making the derivative display a little nicer if possible.

Is there a way to do this?

I am using 2019.1 on windows 10.

 

First 138 139 140 141 142 143 144 Last Page 140 of 199