Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are replies submitted by Joe Riel

@Preben Alsholm I also compute the Maple version in the initialization file and use it to read a local version-dependent initialization file. To be as lightweight as practical, the code I use does not call any Maple library procedures (yours calls StringTools). Here's the code I use

# -*- maplev -*-
#
# User initialization file for Maple.
#
# Read the appropriate initialization file,
# depending on the major release of Maple.
# If, for example, the major release is 9
# then the Maple file $HOME/etc/maple/maple9.mpl is read.

proc()
local initfile, ver;
    try
        ver := kernelopts('version');
        ver := sscanf(ver, "Maple %[0-9]");
        initfile := cat(NULL
                        , kernelopts('homedir')
                        , "/etc/maple/maple"
                        , ver[1]
                        , ".mpl"
                       );
        read initfile;
    catch "unable to read":
        error "cannot read initialization file %1", initfile;
    end try:
end proc():
"ignore this; it's in ~/.mapleinit to prevent Grid from doing something bad; see SCR 75385":

Ignoring the goto issue for the nonce, you can use elif here to avoid further nesting.

if x=10 then
   ...
elif x=12 then
   ...
...
end if

@nm Use forward-quotes to protect the options. They should never be declared as locals, that won't work as the procedure (plot3d here) won't recognize them. For example, do

plot3d( ... ,  'axes = none', 'projection' = 0.9, ... );

Followup Note that you can declare, say, axes, as a local in the calling procedure, but if so, you will need to prepend the colon-dash operator to the axes symbol used as an option to plot3d so that it refers to the global variable. For example

foo := proc()
local axes;
      ...
      plot3d( ... , ':-axes = none', ... );
      ...
end proc:

More typical might be

foo := proc()
local axes;
    ...
    axes := 'none'; 
    plot3d( ... , ':-axes' = axes, ... );
    ...
end proc:

 

@Carl Love cat works in place of the || operator and is preferred. See the note in the help page for ||.

@acer I had considered using unapply with piecewise, as you did in one of the examples, but wasn't wild about piecewise. That can be avoided by using forward quotes around ifelse (or `if`) to prevent premature evaluation: 

six := 'ifelse'(R <= x^2+y^2, s, E[2]*((3*nu[2]-1)*E[1]+(1-3*nu[1])*E[2])/((E[1]+2*E[2])^2-(nu[2]*E[1]+(1-nu[1])*E[2])^2)):
si := unapply(six, x,y);

@Pascal4QM Note that the Emacs debugger should work on linux, windows, and a mac, though I haven't used it on a mac. The current source is https://github.com/JoeRiel, it's called mdcs.

@Mac Dude You should also be pestering me to release the current version of the Emacs Maple Debugger, in an easily installable package. The source is on github. I use it constantly and should probably create a video demonstrating it. It has all the features the original poster desired, and then some.

@tomleslie Good point.  That's one of the dangers of suggesting an answer without actually trying it 8-).

I find the use of until in your example to be cleaner and clearer than the alternatives.  It is shorter and avoids assigning and declaring a boolean variable.  Is it a huge improvement?  I think not, but it has its occasional uses. Note that while you state that end do is the normal termination, easier to read, etc., in your examples you use the older form, od.   

@Kitonum Somewhat cleaner might be

seq(x < 1, x=P_X);

Hi Ian.  I wrote that a long time ago, before modules, etc.  It should be completely rewritten. Not even sure if I still have the original source, which, if I recall correctly, was written in a custom pseudo-literate style that allowed mixing LaTeX with Maple code. Fun stuff. I think I have the printed typeset output in a binder; will look into it shortly.

Further The documentation hasn't turned up. Where'd you get the package? Because _e has the antisymmetric index, it will automatically return zero if an index is repeated. See ?indexfcn,antisymmetric.  

@Mariusz Iwaniuk Here's a somewhat crude way to do that

(**) y := 2*4^n;                     
                                            n
                                    y := 2 4

(**) evalindets(y,integer,ifactor);
                                       2 n
                                  ( (2) )   (2)

(**) simplify(%,power);            
                                      (2 n + 1)
                                   (2)

@acer I should convert your reply to an answer so as to allow an upvote. 

It's not clear what you are asking.

@rlopez  Nice, thanks for pointing it out. 

First 27 28 29 30 31 32 33 Last Page 29 of 195