Joe Riel

9660 Reputation

23 Badges

20 years, 6 days

MaplePrimes Activity


These are replies submitted by Joe Riel

It would be useful to have a table/page listing Maples features by release. This seems a case where a wiki would be ideal---easy for someone to start, and convenient for others to fill in the details and update.
As do I, which is why I'm disappointed that there hasn't been an enthusiastic response to the suggestion (besides yours). It seems like it would be a good fit, and potentially quite useful.
Why don't you post your revised code with the index variables fixed. I don't want to guess which variables are supposed to be indexed by the i in the do loop, and which are supposed to be indexed by the i in the add/sum function.
Why don't you post your revised code with the index variables fixed. I don't want to guess which variables are supposed to be indexed by the i in the do loop, and which are supposed to be indexed by the i in the add/sum function.
Your observation is correct. Maple's remember option uses the arguments that are passed to the procedure, not default values. The lookup in the remember table occurs before default processing, so if there is a match, the remembered value is returned and the default values (of arguments) are not used or even evaluated. You can partially see this by doing
g := proc() option trace; 3 end proc:
f := proc(x:=g()) option trace,remember; x end proc:
f();
{--> enter g, args = 
                                       3

<-- exit g (now in f) = 3}
{--> enter f, args = 
                                       3

<-- exit f (now at top level) = 3}
                                       3
Calling f() again returns the value stored in the remember table. The default expression, g(), is not evaluated.
f();
value remembered (at top level): f() -> 3
                                       3
Calling f with the default value as the actual argument does not return the value from the remember table because the actual default value (from previous call) is not stored (as an index) in the table.
f(3);
{--> enter f, args = 3
                                       3

<-- exit f (now at top level) = 3}
                                       3

f(3);
value remembered (at top level): f(3) -> 3
                                       3
Considering that the book entries I have made took considerably more effort than a quick response to a question, it seems reasonable that a book entry gets more points. Naturally this could be abused, but it's not like we're getting a rebate at the end of the year. Still, weighting by number of views seems like a good idea, at least in theory. If collaborative books were the goal, the better approach would be to have a wiki system.
Yes, I too miss that rating. The disappearance of the "Most Viewed" sidebar is probably reasonable since once an entry got on there, it tended to stay, due to the extra hits it generated. But it is nice to be able to see how many times a particular page is accessed.
I suspect that TypeTools was not added until Maple 9. To work around that, use the older method of creating a type: assign a `type/NameOfType` procedure, similar to what you did for the print function. That method still works, its drawback is that it pollutes the global name space.
MyModule := module()
local ModuleLoad;
export PAIR;
option package;
    ModuleLoad := proc()
    global `print/PAIR`, `type/PAIR`;
        `print/PAIR` := proc(a,b) [a, b] end proc;
        `type/PAIR` := x->evalb(op(0,x)=PAIR);
    end proc:
    ModuleLoad();
end module:
Note, by the way, that backquotes are not needed around PAIR. They are only required to enter a name that has none alphanumeric characters. When assigning globals in a ModuleLoad, it is good practice to unassign them in a ModuleUnload. That is, add the following assignment (with a local declaration) to your module
ModuleUnload := proc()
  `print/PAIR` := '`print/PAIR`';
  `type/PAIR` := '`type/PAIR`';
end proc:
I suspect that TypeTools was not added until Maple 9. To work around that, use the older method of creating a type: assign a `type/NameOfType` procedure, similar to what you did for the print function. That method still works, its drawback is that it pollutes the global name space.
MyModule := module()
local ModuleLoad;
export PAIR;
option package;
    ModuleLoad := proc()
    global `print/PAIR`, `type/PAIR`;
        `print/PAIR` := proc(a,b) [a, b] end proc;
        `type/PAIR` := x->evalb(op(0,x)=PAIR);
    end proc:
    ModuleLoad();
end module:
Note, by the way, that backquotes are not needed around PAIR. They are only required to enter a name that has none alphanumeric characters. When assigning globals in a ModuleLoad, it is good practice to unassign them in a ModuleUnload. That is, add the following assignment (with a local declaration) to your module
ModuleUnload := proc()
  `print/PAIR` := '`print/PAIR`';
  `type/PAIR` := '`type/PAIR`';
end proc:
How is that any different from using any other device (list, set, record) as a Maple data structure?
Note that has_unit is a useful, but undocumented, type. Here's a procedure that encapsulates Dave's suggestion:
UnitsToUnity := proc(x, sys := SI)
    if sys = 'None' then
        subsindets(x, has_unit, rcurry(convert, 'unit_free'));
    else
        subsindets(x
                   , has_unit
                   , u -> convert(combine(u, 'units', 'system'=sys), 'unit_free')
                  );
    end if;
end proc:
UnitsToUnity( Unit(ft)/Unit(m) );
                                      381/1250
                              
UnitsToUnity( Unit(ft)/Unit(m), None );
                                        1

UnitToUnit( Unit(m), FPS);
                                       1250/381
Note that has_unit is a useful, but undocumented, type. Here's a procedure that encapsulates Dave's suggestion:
UnitsToUnity := proc(x, sys := SI)
    if sys = 'None' then
        subsindets(x, has_unit, rcurry(convert, 'unit_free'));
    else
        subsindets(x
                   , has_unit
                   , u -> convert(combine(u, 'units', 'system'=sys), 'unit_free')
                  );
    end if;
end proc:
UnitsToUnity( Unit(ft)/Unit(m) );
                                      381/1250
                              
UnitsToUnity( Unit(ft)/Unit(m), None );
                                        1

UnitToUnit( Unit(m), FPS);
                                       1250/381
did you forget to convert a <?
did you forget to convert a <?
You can put the assignment in the Maple initialization file. See ?maple for details. For linux, create a text file ~/.mapleinit with the line
libname := "/home/yourname/maple/lib/newdossier", libname:
More useful might be something like
# ~/.mapleinit - Maple initialization file
# This is read each time Maple is started or restarted.
# Assign global variable mylib and reassign libname and savelibname to use it.

mylib := "/home/yourname/maple/lib/newdossier":  # adjust as appropriate
libname := mylib, libname:
savelibname := mylib:
First 168 169 170 171 172 173 174 Last Page 170 of 195