Joe Riel

9660 Reputation

23 Badges

20 years, 4 days

MaplePrimes Activity


These are answers submitted by Joe Riel

You can use ?LibraryTools[Browse].  I find it a bit clunky, and it occasionally does not format the code properly, i.e. does not call showstat when it should have, but it has its uses.

To make it easier, I added the source file to the zip file (and fixed a minor bug).  See the original post; the new zip file is version 0.2.  The source isn't the cleanest. I originally wrote this just to have a SHA1 algorithm, then later extended it to SHA2.

M := Matrix(8, [0, 0, 0, 0, 0, 0, 0, 0,
                0, 1, 1, 1, 1, 1, 1, 0,
                0, 1, 0, 0, 0, 0, 1, 0,
                0, 1, 0, 1, 1, 0, 1, 0,
                0, 1, 0, 0, 0, 0, 1, 0,
                0, 1, 0, 0, 0, 0, 1, 0,
                0, 1, 1, 1, 1, 1, 1, 0,
                0, 0, 0, 0, 0, 0, 0, 0
               ]):
with(ImageTools);
ImgM := Create(M):
Preview(ImgM);

You can also you View, but the result is quite small.

Here's a slight variation of Acer's method. 

`++` := proc(x::uneval) x := eval(x)+1; _rest end proc:
cnt := 0:
seq(`++`(cnt,i), i=1..4);
                                  1, 2, 3, 4

cnt;
                                       4

Are you working with a particular package?

Try the ?sprintf function.  For example

filename := sprintf("parameter-name=%a.txt", value);

The error message is explicit; it is expecting an integer.  The only issue is which %d format is not being passed an integer. The answer is 'unitweight', it is a float.  Try changing the particular %d to %f or %a.

The usual way to do this is with ?unapply.  For example,

t := 3:
f := unapply(x*t, x):

However, for that to work one generally needs an expression (here x*t) to convert to a procedure.  That can be a bit tricky when, instead, you have a procedure.  One way is to use the curry procedures (?curry and ?rcurry).

g := (x,y) -> x*y:
t := 3:
f := curry(g,t):

In the template you gave we can do

MyProcedure := proc(list_of_values)
local l_funcs;
l_funcs := map2(curry, SomeFunction, list_of_values);
plot(l_funcs, 0..10);
end proc:

You can use print, as in print(f).  However, why not just return the polynomial instead of printing it.

Use Format -> Manage Style Sheets to make the style of the current worksheet the default. The operation is not difficult, but also is not obvious. There are help pages that describe how to do so, but there really should be a link from the dialog to those help pages, I'll submit that as an SCR

.

 

It is possible to get this to work, see these examples, (none precisely address your question, but the large example I gave uses readline to pipe stuff through maple) however, this generally is not the easy way to go and I do not see any compelling reason here for doing so.  Using readline and shell passing in maple, at least for me, has always been tricky.

Terminate the print command with a colon.  That will prevent the empty list/set, which is the result of mapping print over a list/set, from being printed.

Use the ?try statement

For example

ignore := proc(x)
   try
       1/x;
   catch:
   end try;
   x;
end proc:
ignore(0);
                     0

I didn't see mention of the ?member procedure, which takes an optional third argument that, if the element is found, is assigned the index of the first matching position.  The help page suggests that that only works for sets, lists, and modules, but testing indicates that it works with other structures as well.  For example,

(**) M := <1,2;3,4;5,6> ;            
                                      [1    2]
                                      [      ]
                                 M := [3    4]
                                      [      ]
                                      [5    6]

(**) member(3,M,'pos');
                                     true

(**) pos;
                                     2, 1

 

Not rigorous, but assume we start at t=0 and n events occur at t1, t2, ..., tn The mean arrival rate is, I believe, n/tn.

The mean inter-arrival time is 1/n*(t1-0 + t2-t1 + t3-t2 + ... + tn-t(n-1)) = 1/n*tn.  There may have been some fudging with the end points, but you get the idea

First 54 55 56 57 58 59 60 Last Page 56 of 114