Joe Riel

9630 Reputation

23 Badges

19 years, 241 days

MaplePrimes Activity


These are replies submitted by Joe Riel

@nm The export CartesianProduct also has this problem.  Am looking into it.

@acer Using return is clever.  Here's a tweak to improve the error message (the actual coercion is not ideal)

restart;
kernelopts('assertlevel'=2):
~set := proc(y::rtable)::set; return convert(y,list) end proc;
foo6 := proc(x :: ~set) x end proc:
foo6(<0>);

Error, (in ~set) assertion failed, ~set expects its return value to be of type set, but computed [0]

Interesting.   That works, but fails without the nonsense call to blah(blech).  I haven't yet comprehended that.  Replacing blah(blech) with, say, NULL also works, but is no less confusing.

The following may do what you want.

restart;
kernelopts(assertlevel=2):
foo := proc(x::coerce(set, (y::rtable) -> convert(y, list))) :: set; x end proc:
foo(<0>);
Error, (in foo) assertion failed, foo expects its return value to be of type set, but computed [0]

That response bypasses your actual request, which I believe is to have the coercion procedure check that it returns the desired type.  I don't know whether that is possible.  The following is a failed attempt to do that, it moves the return type to the coercion procedure.

foo := proc(x::coerce(set, proc(y::rtable) :: set; convert(y, list) end proc)) x end proc:
foo(<0>);
                     [0]

 

@acer That was why its labled non-robust.  Seems unlikely the other extensions typically occur.  The method you gave is better. This one was amusing; I should have mentioned that.

@Ronan Forward quotes should not typically be used when declaring parameters, however, in your case they are needed in the predicate.  The predicate can be eliminated with a slight restructuring.  First, you don't need to check for both row and column vectors, just check for a vector with three elements.  Second, you can eliminate the satisfies by including the type for the elements in the Vector declaration (see the help page for type/Vector). The following works

test := proc(V::Vector(1, Vector(3)))
    print("works");
end proc:

The Vector(3) is the type for each element (there is only one) of the outer Vector.

@jrive I believe the latest version of Syrup is available on the Maple cloud and has version 0.2.8.

@nm Using false as the condition causes the conditional to be removed from the code by the simplifier, which is generally a good thing.  I recently had a reason for keeping the code in a procedure, so used 1=0 for the condition.

@Carl Love I frequently use tty maple (on linux), so when copying, the prompts are included.  I switched to "(**)" as the prompt for that reason.

@nm there is a workaround.  Declare the object as a named module (see the help ?module,named).  Instead of

person := module() ... end module:

do

module person() ... end module:

 

@nm In this case, because the string you want to match ends at the right brace, but doesn't include another right brace, you can replace, in the 2nd group, ".*" with "[^}]*".  For example

s := "A& {test} & \\textrm{The fundamental matrix has } &C & {test} ":
S := StringTools:-RegSubs("(.*)\\\\textrm\\{([^}]*)\\}(.*)" = "\\1\\begin{minipage}{\\linewidth}\\textrm{\\2}\\end{minipage}\\3", s);

which produces
 

"A& {test} & \begin{minipage}{linewidth}\textrm{The fundamental matrix has }\end{minipage} &C & {test} "

 

@dharr  Your example is interesting.  The sizes of the two submatrices don't match, so it's not immediately obvious what should happen.  From testing we see that the A[7, 8..11] is assigned [0,0,0,0].

@Carl Love  There is a "simpler" approach (simple to me, because I wrote Syrup).  In the original, click in the code edit region and rename it to ckt2 (change the name in Code Edit Panel on the right, you might have to turn it on in the worksheet). Also, change its language from Maple to something else (I'm using Plain Text, but that wasn't an option until recently, so you could also use Modelica). 

I'll attempt to improve the error message that Solve is generating with the original.

@sand15 It's an interesting approach.  While the presented code doesn't explicitly use while loops, ifactor does, and it is called by ifactors. 

Did you get maplev-mode from Maplesoft or from GitHub?  I was out of action for most of last year and haven't done anything with either version.   The version of maplev-mode I use here is more recent than any I have pushed. 

1 2 3 4 5 6 7 Last Page 1 of 195