Message Boards Message Boards


Issues with Module fuction when developing a package

Posted 4 months ago
1 Reply
0 Total Likes

I am trying to develop my own package, which contains fuctions that helps kinematic calculations. One of these fucntion: enter image description here

My problem is, that in my notebook, the function works properly only if I evaluated the cell in my package where the function is (with shift+enter). Before that, I always get a null matrix which means my notebook sees the function, but I think the local variables in the Module function (a,b,c) are not evaluated. I tried with Evaluate function but this did not work either. I found the following in the Mathematica documentation: enter image description here I think this can be related somehow to my problem, but i am not sure and i do not really understand what is the difference between Function[x,e] and <a href="mailto:Function@@{x,e}">Function@@{x,e}. To sum up: After shift enter in the package, the function works properly in notebook, before shift enter, it works incorrectly. Why is that. Thank you and sorry for my bad english.

Posted 4 months ago

You didn't show the code of your package, so I am assuming the code you provided was wrapped by the package commands.

As I understand things, code (including packages and functions) must be evaluated before they will work as expected.

Of course, since the Wolfram language is symbolic, you will often get an answer, even if packages and functions are not yet evaluated.

There are several ways to get your package evaluated before the code that uses it:

  • Shift-enter (or use the evaluation menu) in the cell that contains the package
  • You can put the package code into another file and use Needs[] to evaluate the package
  • You can put the package code into another file and evaluate it with Needs at start up in your kernel/init.m file
  • and more

Good Luck

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract