4
$\begingroup$

Sometimes after I load the Combinatorica package by entering Needs["Combinatorica`"], I need to use Mathematica for something like:

PermutationGroup[{Cycles[{Range[10]}]}] // GroupElements. 

I get this message:

GroupElements::perm: Cycles[{{1,2,3,4,5,6,7,8,9,10}}] is not a valid permutation. >> GroupElements::argr: GroupElements called with 1 argument; 2 arguments are expected. >>.

In other words, it doesn't work!

Is there a way to temporarily suspend the Combinatorica package. Right now I have to shut down Mathematica and restart it.

$\endgroup$
9
$\begingroup$

You'll want to manipulate $ContextPath. The following will do:

removeCombinatorica[] := (
 oldContextPath = $ContextPath;
 $ContextPath = DeleteCases[$ContextPath, "Combinatorica`"];
)

readdCombinatorica[] := ($ContextPath = oldContextPath;)

Then you can call removeCombinatorica[] before whatever you want to ignore Combinatorica, and readdCombinatorica[] after you've done it.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.