Search code examples
maxima

How to avoid name collision in Maxima


I'm learning by reading Maxima manual.

Maxima has many built-in functions and global variables. I worry about the possibility of overwriting the same name function or variable which already exists.

Is there a convenient way to avoid the name collision in Maxima?


Solution

  • If you are talking about namespaces, - no, I've never heard of namespaces in Maxima.

    • the easiest way to solve your problem is to write prefixes to user-defined variables and functions

    • another option is to check if function\variable already exists via describe(FUNCTIONNAME). If it prints text, than function is predefined =)

    Code example:

    a:1;
    b:2;
    map:3;
    map(describe, values);
    
    (%o25) 1
    (%o26) 2
    (%o27) 3
    No exact match found for topic a.
      Try ?? a (inexact match) instead.
      No exact match found for topic b.
      Try ?? b (inexact match) instead.
     Function: map (<f>, <expr_1>, ..., <expr_n>)
         Returns an expression whose leading operator is the same as that
         ....
         ....
      There are also some inexact matches for map.
      Try ?? map to see them.
    (%o28) [false,false,true]