Skip to main content
deleted 67 characters in body
Source Link
Rojo
  • 42.8k
  • 7
  • 98
  • 190

I am not sure these are the best ways but they should work. You could do what you did with Dimensions for all the symbols in Combinatorica`

For example, running this

replaceAndLoad[context_String -> toContext_String] := 
 Block[{$ContextPath},
  Needs[context];
  Scan[ToExpression[
     toContext <> StringReplace[#, context ~~ sym__ :> sym] <> 
      "=" <> #] &, Names[context <> "*"]]
  ]

Now, do

replaceAndLoad["Combinatorica`" -> "Com`"]

You could also overload MakeExpression to change Com to Combinatorica at the parsing stage... But I would probably do something different and basic, like an InputAlias or InputAutoReplacement, or Ctrl+k, to type faster. If you use InputAlias or InputAutoReplacementsWith these you could even replace them with a framed box in a special color that means "context combinatorica", or a tooltip, or simply an Interpretation that writes Com`stuff but is interpreted as Combinatorica` ...

I am not sure these are the best ways but they should work. You could do what you did with Dimensions for all the symbols in Combinatorica`

For example, running this

replaceAndLoad[context_String -> toContext_String] := 
 Block[{$ContextPath},
  Needs[context];
  Scan[ToExpression[
     toContext <> StringReplace[#, context ~~ sym__ :> sym] <> 
      "=" <> #] &, Names[context <> "*"]]
  ]

Now, do

replaceAndLoad["Combinatorica`" -> "Com`"]

You could also overload MakeExpression to change Com to Combinatorica at the parsing stage... But I would probably do something different and basic, like an InputAlias or InputAutoReplacement, or Ctrl+k, to type faster. If you use InputAlias or InputAutoReplacements you could even replace them with a framed box in a special color that means "context combinatorica", or a tooltip, or simply an Interpretation that writes Com`stuff but is interpreted as Combinatorica` ...

I am not sure these are the best ways but they should work. You could do what you did with Dimensions for all the symbols in Combinatorica`

For example, running this

replaceAndLoad[context_String -> toContext_String] := 
 Block[{$ContextPath},
  Needs[context];
  Scan[ToExpression[
     toContext <> StringReplace[#, context ~~ sym__ :> sym] <> 
      "=" <> #] &, Names[context <> "*"]]
  ]

Now, do

replaceAndLoad["Combinatorica`" -> "Com`"]

You could also overload MakeExpression to change Com to Combinatorica at the parsing stage... But I would probably do something different and basic, like an InputAlias or InputAutoReplacement. With these you could even replace them with a framed box in a special color that means "context combinatorica", or a tooltip, or simply an Interpretation that writes Com`stuff but is interpreted as Combinatorica` ...

Source Link
Rojo
  • 42.8k
  • 7
  • 98
  • 190

I am not sure these are the best ways but they should work. You could do what you did with Dimensions for all the symbols in Combinatorica`

For example, running this

replaceAndLoad[context_String -> toContext_String] := 
 Block[{$ContextPath},
  Needs[context];
  Scan[ToExpression[
     toContext <> StringReplace[#, context ~~ sym__ :> sym] <> 
      "=" <> #] &, Names[context <> "*"]]
  ]

Now, do

replaceAndLoad["Combinatorica`" -> "Com`"]

You could also overload MakeExpression to change Com to Combinatorica at the parsing stage... But I would probably do something different and basic, like an InputAlias or InputAutoReplacement, or Ctrl+k, to type faster. If you use InputAlias or InputAutoReplacements you could even replace them with a framed box in a special color that means "context combinatorica", or a tooltip, or simply an Interpretation that writes Com`stuff but is interpreted as Combinatorica` ...