4

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.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Geoffrey Critzer
  • 1,661
  • 1
  • 11
  • 14
  • Related: https://mathematica.stackexchange.com/questions/37674/creating-a-custom-context-with-a-hold-construct (hat-tip Oleksandr) – Patrick Stevens Aug 22 '15 at 21:15

1 Answers1

10

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.

Patrick Stevens
  • 6,107
  • 1
  • 16
  • 42