Carl Love

Carl Love

20853 Reputation

24 Badges

8 years, 194 days
Natick, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity

These are questions asked by Carl Love

I hate it when a user bumps every Question that they've ever asked over the past five years to the top of Recent (aka Active Conversations) stack! This is not the first time that this has happened. I rely heavily on that stack being truly the threads with the most-recent material. Can't something be done about this short of deleting the threads? That seems too drastic: While this user has occasionally been a pest in the past, they've also posted some decent material. There should be some way for a moderator to just reset the stack positions to what they were previously.

Here's a slightly reduced form of a little module from some code that I posted recently:

KandR:= module()
   a, b, c, e, #parameters

   #procedure that lets user set parameter values:
   ModuleApply:= proc({
       a::algebraic:= KandR:-a, b::algebraic:= KandR:-b, 
       c::algebraic:= KandR:-c, e::algebraic:= KandR:-e
   local k;
      for k to _noptions do thismodule[lhs(_options[k])]:= rhs(_options[k]) od;
   end proc
end module:

The purpose of the module is simply to be a container for the four parameters and to provide a simple ModuleApply interface by which they can be set, reset, and/or unset. 

I very often use a procedure parameter of a ModuleApply to set a local variable of same name in the module. Because of the name conflict, thismodule needs to be used in these situations. I see this as the primary use of thismodule. In the module above, the purpose of the line 

for k to _noptions do thismodule[lhs(_options[k])]:= rhs(_options[k]) od;

is to avoid the need to explictly use the parameters yet a third time. First off, I am amazed that this works! I've had many disappointments with thismodule (which is essentially undocumented---its miniscule help page is nearly worthless). I am using Maple 2018, release 1. Another Maple 2018 user (not sure which release) reports that the above line gives an error (when executed) that thismodule's index must be a name.

Question 1: What's up with that?

[Edit: It's been determined that the problem was due to an unfortunate global assignment in that user's initialization file rather than different behavior of thismodule. So, I consider Question 1 to be completely answered, and it should be ignored.]

Question 2: The for loop is not entirely satisfying to me. Is there a better way?

[Status: Answered, see below.]

Question 3: Ideally, I'd like to explicity use the four parameters once, not two or three times. Is there a way? If I need to use a container for the parameters (such as a Record), to achieve that, I'd be happy to do that, and I wouldn't mind needing to invoke that container's name any number of times.

[Status: Answered, see below.]

Note that op and exports can be applied to thismodule to extract the module's operands. I have found this occasionally useful.

Question 4: What are some other good uses for thismodule? The one and only example given on its help page seems ridiculous to me.

What's going on here? Am I missing something, or is it a bug? If it's a bug, then it's by far the deepest and most profound bug that I've ever found or seen in Maple (and I've seen thousands over the decades). And since that surprises me, my guess is that I'm missing something obvious.

Op:= (R,F)-> F(['R()'$2]):
Op(rand(1..9), [f,f]);
                     [f([7, 6]), f([2, 4])]

The expected output is [f([7,6]), f([7,6])]. The same thing happens if I replace with seq, or if I replace -> with proc.

The page ?type,piecewise shows the example

type(piecewise[](x < 1, a, b), 'piecewise');

and lines 4-8 of showstat(`print/piecewise`) deal with the case of an indexed piecewise. Yet I can find no other reference to indexed piecewise. What is it used for? When I put an index on a piecewise, nothing special seems to happen, either computationally or display-wise:

piecewise[abs](x > 0, x, -x);
piecewise[Carl](x > 0, x, -x);

The code in `print/piecewise` suggests that it serves some purpose.

When I try to use CodeTools:-Profiling:-Profile() (with no arguments), I get "kernel connection lost" after about a minute. Has anyone used this sucessfully, with no arguments? If so, would you please post a worksheet? I'm using Windows 8, if that makes a difference.

I think that I'll need to revert to the older kernelopts(profile= true).

1 2 3 4 5 6 7 Page 3 of 8