Joe Riel

9660 Reputation

23 Badges

20 years, 10 days

MaplePrimes Activity


These are replies submitted by Joe Riel

There is also a maplemint procedure. I don't use it, preferring the more capable standalone program, but it can be used inside the GUI.
It's not bijective on the domain.
X := [1001^2,1001,1]:
inner([0,1,-1],X) = inner([0,0,1000],X);
                                1000 = 1000
Actually, since attributes are used, it only has to be injective (and preserve ordering). That can be fixed, but will slow down the computation.
The Maple initialization file can and should be created/modified. It can reassign libname so that any Maple session can find a user library. One of the many advantages to coding in an external editor and saving to an mla (Maple archive) rather than using the read commmand in Maple is that you can then use preprocessor macros. The most useful is $include (see ?preprocessor). It allows you to split a module assignment into multiple files. For example:
mymodule := module()
export function1, function2;
$include "function1.mpl"
$include "function2.mpl"
end module:
Whether this is an advantage to the user depends on the ability/preference to work with multiple files versus a single large file. And that depends somewhat on the editor/os environment. If your editor permits working on only one file at a time, then you will want to instantiate multiple editor sessions. That wasn't feasible/practical when I first started writing Maple code, on a win 95 machine, so I usually kept all the source code in one large file.
There is a minor problem with your encoding scheme, it doesn't work with the mix of positive and negative integers implied by the assignment to r, the random number generator. Note that in the range of 1..255, Robert's method is substantially faster, especially as the sublists increase in length.
Yes, if you do go the route of using an external editor, you will have to invest some time in setting it up and learning to use it effectively. I use Emacs, for which the investment is larger than most. The reward, however, is commensurate (or is that commiserate 8-). I almost never copy and paste between the editor and Maple, at least not in the way you envision. When working on a small procedure, I just send the entire procedure to Maple (the Emacs mode has a command for doing so). I can also send it to mint, which does syntax checking and highlights errors. Or click on a procedure name and immediately bring ups its help page. It is quite effective. For larger stuff, I generally have a separate test file, "compile" the code and save it to a library, and then run the test file, which may also have debugging commands embedded. Compilation and execution is done in a separate shell, but is usually done with one or two keystrokes (using the shell's command history).
More generally I think you'd want something like
 StringTools:-RegSubs("([0-9]),([0-9])"="\\1.\\2", "0,78 + 23,4");
                                 "0.78 + 23.4"
More generally I think you'd want something like
 StringTools:-RegSubs("([0-9]),([0-9])"="\\1.\\2", "0,78 + 23,4");
                                 "0.78 + 23.4"
Yes. Note that the same occurs using the `if` function, that is, `if` uses special evaluation rules, so only the needed parameter is evaluated. You could have done
`if`(L1=L2,true,subs(0=NULL,L1-L2)[1] < 0)
Actually, there is a subtle flaw in that, which your procedure shares. The result returned is not of the type truefalse, instead it may be a relation, say, 1 < 0. Apparently sort is able to deal with that, so it isn't really a flaw, but I think it is better to call evalb, that is,
`if`(L1=L2,true,evalb(0=NULL,L1-L2)[1] < 0))
Using the or returns truefalse without the evalb
That is a clever technique. Your sortLists procedure can be improved. Here is faster version
sortLists := proc(L1,L2)
   L1 = L2 or subs(0=NULL,L1-L2)[1] < 0;
end proc:
Alas, that isn't as fast as using the standard element by element comparison, at least not for typical lists. Besides, the element-by-element comparison is more general in that it works with lists of differing sizes.
Pushing the notation further, we have
plot(sin/exp, 0..2*Pi);
Pushing the notation further, we have
plot(sin/exp, 0..2*Pi);
I hadn't thought of D@@0, which is cute, though, as you suggest, not always workable. A more general possibility is op@`[]`. It is equivalent to ()->args, which is what I normally use if the identity must handle sequences. Otherwise I'll use the simpler x->x.
I hadn't thought of D@@0, which is cute, though, as you suggest, not always workable. A more general possibility is op@`[]`. It is equivalent to ()->args, which is what I normally use if the identity must handle sequences. Otherwise I'll use the simpler x->x.
You can pass multiple arguments to identical. So I'd do
A := remove(type, [anames(builtin)], identical(`?[]`, goto, assemble, disassemble, pointo, DEBUG, RETURN, `**`, `^`));
`^`();
is 7 keystrokes, and I suppose one could leave off the semicolon in 2D mode, but that's cheating.
First 158 159 160 161 162 163 164 Last Page 160 of 195