Joe Riel

8054 Reputation

22 Badges

15 years, 18 days

MaplePrimes Activity

These are questions asked by Joe Riel

What is an efficient, robust, way to extract an integer coefficient from a single term? My first thought was using lcoeff, however, it doesn't work if the term contains constants (say Pi) or floats. Currently I'm using patmatch,
icoeff := proc(t)
local k,x,kx;
  return `if`(patmatch(t, k::'nonunit'(integer)*x::anything,kx)
end proc:
map(icoeff, [0, 1, -3.0, -3, -0.,  3.0*Pi, 4*Pi, -12/5*I]);
                           [0, 1, 1, -3, 1, 1, 4, 1]
What is the proper method for converting an extended numeric with a zero imaginary component to a real? It should leave the complex part alone if it is not zero. That is, somefunc(1.0 + 0.*I); 1.0 somefunc(1.0 + 1.*I); 1.0 + 1.*I I can write my own procedure, but there must be standard way (somefunc) to do this. Searching the help browser didn't help. Thanks.
I'm trying to trap the exception generated when the member operator (:-) is used with a variable that is not a module. I thought the following would work:
    catch "`NotAModule` does not evaluate to a module":
        print("it worked")
        print("it failed");
    end try
end proc();
                                  "it failed"

                 "`NotAModule` does not evaluate to a module"
Any ideas how to fix this? The generated exception string should match the first catch statement.
I've looked at Alec Mihailov's interesting web page describing how to use the Microsoft assembler (MASM) to create a DLL that can be called by a Maple procedure. I'm attempting to rewrite the code using the GNU assembler (as) and have a few questions. Page 331, section 6.2 of the Maple 10 Advanced Programming Guide states that, to create a DLL, "the external library functions must be compiled by using the _stdcall calling convention, which is the default under UNIX but must be specified when using most Windows compilers." This leaves me somewhat confused. My limited understanding is that the stdcall calling convention has two effects:
The help page for StringTools:-FormatTime states that the %Z specifier returns the time zone, if available. On my system (linux), it just returns the string "???". For example,
Is there a way to get this to work?
1 2 3 4 Page 3 of 4