ianmccr

165 Reputation

6 Badges

15 years, 306 days

MaplePrimes Activity


These are replies submitted by ianmccr

@acer 

 

I had to change input and output to 2D math notation for extended typesetting to take effect. However, your advice solved the output problem.

@acer 

I don't know how to edit the post to remove the upload, but if the monitors wish to remove it, I understand the concern. I am open to suggestions as to how I should present the question, but, fundamentally, I believe the problem is the result of the namespace in an installed package. The code itself is copied straight from the maple examples, and my worksheet repeats the examples given on the help page for the module's exports, but the results are different when installed.

@Carl Love 

Glyph2Zip.zip

Here's the zipped workbook.

@Carl Love 

Thank you. I'll try the inert multiplication. This saved me a lot of time trying to finesse the output.

@tomleslie 

Thank You.  I have played around quite a bit with the code that Carl posted. I think I finally have a feel  for how the execution paradigm works, enough that I can apply it myself I appreciate that quite a bit of Maple's power comes from the ability to return a procedure unevaluated, but the case of how to actually generate results doesn't leap out from the help examples or the programming guide.  The only reference in help that I can find is "special evaluation rules."  However, modifying "end proc" to "end proc() doesn't leap off the page unless considered in the light of the examples in this thread. Ian Thompson's book does touch on the subject, but lightly. I'm going to take a close look at your sample code in the same light. 

It is interesting to note that Help documents the use of the :- operator without the left operand as a means of calling the global instance of a procedure when there is a local instance of the same name. I recall this was actually used in some sample code (Quotient Field of the Polynomial Ring) in the Maple 8 programming guide, specifically  gcd:=(a,b)->:-gcd(a,b) .

@tomleslie

You can't find yourself unless you first get lost.  With Carl's modifications to my worksheet, I can experiment a bit with the effects of changes to the code.  However, given our recent discussion, I am starting to wonder whether the procedure I store in the table can, in turn, make a call to another procedure defined elsewhere in the module. Are there any limitations on the complexity of the statement sequence of the stored procedure.

@tomleslie 

 I have tried you sample and it works.  My goal here is to set up the environment for a clifford algebra which uses a procedure to define dimension, minindex, maxindex, and a table representing the metric.  I intended to include calls to addspace at the end of the module so it would Ioad the metrictable with four or five different calls to a local procedure Assignspace(Dim,table['identity'] or the like).  This way the user can choose the metric environment to be used.  Then the call to GetSpace would set up the default environment when the module loads. (Something like the programming sample diffimpl does to create a database of functions for use by the parser.)  I am still trying to get a handle on the evaluation rules and  I didn't catch the syntactic distinction between evauluating a procedure and executing it.  Thank you for clarifying the rules for me.

I have attached a worksheet, but this is the code I was testing.testmodule.mw

restart;
Glyph2 := module()
    export    AddSpace, GetSpace, RemoveSpace,DoSpace;
    local     MetricTab;

    MetricTab := table():

    AddSpace := proc( theName::symbol, implementation )
        local    old_imp;
        old_imp := NULL;
        if assigned( MetricTab[ theName ] ) then
            WARNING( "replacing existing extension `%1'", theName );
            old_imp := eval( MetricTab[ theName ] )
        end if;
        MetricTab[ theName ] := eval( implementation, 1 );
        eval( old_imp, 1 )
    end proc;

    RemoveSpace := proc( theName::symbol )
        if assigned( MetricTab[ theName ] ) then
            MetricTab[ theName ] := evaln( MetricTab[ theName ] )
        end if;
        NULL
    end proc;

    GetSpace := proc( theName::symbol )
        if assigned( MetricTab[ theName ] ) then
            eval( MetricTab[ theName ], 1 )
        else
            NULL
        end if
    end proc;
    AddSpace('default','proc() print("Metric is default")end proc');
    GetSpace( 'default');   
end module:
eval(Glyph2:-GetSpace('default'));

I ordered the book from Amazon after I read the post.  The book is full of useful insights that are hard to glean from the help files. I particularly appreciated Appendix B, which summarized the rules for terminating maple language statements. One tends to pick this up by osmosis, but having a summary of the rules for current and older versions of maple is welcome. While the information is probably included in the help files, I wasn't able to find a help page discussing terminating characters in particular.

@Carl Love 

" I fear that you don't have the module "spirit" yet. "  I'm afraid you're correct.  I'm moving forward using code that was written for Maple V and am not quite at the present yet.  All those globals did bother me, but I wanted to have a module that worked so I could play with the code and get a feel for current versions of Maple by experimentation. You're advice is  a helpful start.

@Mac Dude   Maple language does have a steep learning code, but given time, the interpretive capability of the language is its own teaching aid. I agree that the programming guide is excellent, but it is a little disconcerting when I encounter examples,such as the above, that don't work as expected. From an outside perspective, I find it difficult to assess Maplesoft's roadmap for the language. I have been poking through code that was written in the late 90's for Maple V, but, so far, I haven't come across any comparable  public code for applications written after the introduction of modules from which I could gleen effective coding styles. Similarly, I haven't seen a general maple programming book that post-dates MapleV.  Maple is obviously still a dynamic application, but it seems to have moved away from its original role.

@Mac Dude 

Thank you.  I was unaware of the idiosyncrasies of the 2D input parser. This resolves my issue completely. Are there any general maple programming reference books which reflect more modern versions of Maple? I have been using Maple: An Introduction and Reference based on Maple V together with the programming guide.

1 2 3 Page 3 of 3