Joe Riel

9660 Reputation

23 Badges

20 years, 15 days

MaplePrimes Activity


These are replies submitted by Joe Riel

Note that types can and should be extended using TypeTools:-AddType rather than by creating a global name `type/newname`.  Though undocumented, VerifyTools works the same way (with AddVerification) to extend verify. Maybe we need PrintTools and LatexTools 8-).

Thanks, that's the word I couldn't recall.  Amusingly, in light of another thread, the help page for type,atomic uses forward quotes for atomic in the examples despite it being a protected name. That, however, is good practice if unnecessary.

As Robert has pointed out, one can apply this just like a regular procedure.  That is, Maple permits one to apply a list (or set, etc) to arguments.  However, if the original poster really wanted to create a procedure that returns a list of items, rather than a list of procedures, he might do

L := unapply([seq](x*i, i=1..3), x):
                                           L := x -> [x, 2 x, 3 x]

Noting that Maple does

3*[1,2,3];

                [3,6,9]

one might be tempted to do

L := x -> x*[1,2,3]:

however, that only works with elements of type numeric:

L(a);

           a*[1,2,3]

 

Yes, but you don't need map there.  Because the second argument is a name (more precisely, a one operand object [what is the proper term?]), it is equivalent to just applying the function (actually, a list of functions) directly:

L_Israel(x,y,z);
                                 [x, 2 x, 3 x]
L_Riel(x,y,z);
                           [x y z, 2 x y z, 3 x y z]

Louis Riel was a significant figure in Canadian history (not to mention my own family history).  He led the Metis, a blend of native and French settlers, in a revolute against the Canadian government. He was one of the founders of the Manitoba province.  Eventually met his fate at the end of a rope (a few hours before I was born, modulo the year).  The province of Manitoba, last year, designated this day (not historically relevant, but a holiday throughout Canada) as Louis Riel day.

Louis Riel was a significant figure in Canadian history (not to mention my own family history).  He led the Metis, a blend of native and French settlers, in a revolute against the Canadian government. He was one of the founders of the Manitoba province.  Eventually met his fate at the end of a rope (a few hours before I was born, modulo the year).  The province of Manitoba, last year, designated this day (not historically relevant, but a holiday throughout Canada) as Louis Riel day.

Your quibble is relevant.  I'm fairly careful about adding the forward quotes in production code, but that example was proves otherwise. I've been considering adding a typeface in my maplev emacs mode for standard unprotected types but haven't got around to it.

Note, however, that one has to distinguish the usage.  As a rule, one should not use forward quotes in argument declarations, but they are necessary (for protection) in the actual code, as well as local declarations. There have been inconsistencies on this in various releases. 

Mint doesn't complain because it sees freeof(x) as a function call.

Your quibble is relevant.  I'm fairly careful about adding the forward quotes in production code, but that example was proves otherwise. I've been considering adding a typeface in my maplev emacs mode for standard unprotected types but haven't got around to it.

Note, however, that one has to distinguish the usage.  As a rule, one should not use forward quotes in argument declarations, but they are necessary (for protection) in the actual code, as well as local declarations. There have been inconsistencies on this in various releases. 

Mint doesn't complain because it sees freeof(x) as a function call.

Hi John,

Your typing was quicker than mine, but I cleverly replied to the immediate poster rather than the original, so my response appears before yours.  We can split the single point. Congrats on winning the MaplePrime award, that wasn't a surprise.

It's Louis Riel day in Manitoba, so I'll be celebrating, even if I'm not there...

Hi John,

Your typing was quicker than mine, but I cleverly replied to the immediate poster rather than the original, so my response appears before yours.  We can split the single point. Congrats on winning the MaplePrime award, that wasn't a surprise.

It's Louis Riel day in Manitoba, so I'll be celebrating, even if I'm not there...

The + sign doesn't catenate strings in maple, though possibly you weren't suggesting that.  The cat function does.  However, I prefer sprintf here:

for i to 3 do
  fopen(sprintf("file%d.txt", i),'WRITE');
end do;

The + sign doesn't catenate strings in maple, though possibly you weren't suggesting that.  The cat function does.  However, I prefer sprintf here:

for i to 3 do
  fopen(sprintf("file%d.txt", i),'WRITE');
end do;

You should really be using `type', not `is', for the comparison.  That is

getConst := (expr::algebraic,vars::list(name)) -> select(type,expr,freeof(vars)):


 
Note that you may or may not want the following:
 
getConst(f[x]+x + y, [x]);
                                          y
 
That is, type(freeof(f[x],x) returns true. 

You should really be using `type', not `is', for the comparison.  That is

getConst := (expr::algebraic,vars::list(name)) -> select(type,expr,freeof(vars)):


 
Note that you may or may not want the following:
 
getConst(f[x]+x + y, [x]);
                                          y
 
That is, type(freeof(f[x],x) returns true. 

Sorry, for the late response; I've missed quite a bit of fun on my respite from MaplePrimes.  Not so sure about this new editor thing.  Does it handle the less-than issue?

I'll suggest curry, though the result is slightly different:

L := [seq](curry(`*`,i), i=1..3);
   L := [() -> `*`(1, args), () -> `*`(2, args), () -> `*`(3, args)]

Already I cannot stand this editor. Is it possible to change formatting without touching the mouse?
Do one of the silly icons stand for "pre-formatted" and another for "Normal"?  If not, why not?
Using a drop down menu to select such common stuff is painful.
First 154 155 156 157 158 159 160 Last Page 156 of 195