0
$\begingroup$

I have a group of Packages that I use to create a lot of other Packages. Let's see an example:

BeginPackage["testPack`",{"auxPack01`","auxPack02`","auxPack03`","auxPack04`"}]
testFunc::usage="testFunc[]"
Begin["`Private`"]
(*...package code...*)
End[]
EndPackage[]

My question is:

How can I create an auxPack (or some other simplification) so, I can just call it, instead of auxPack01, auxPack02 ... or a variable with all the definitions?

I tried to create a variable

$auxPacks={"auxPack01`","auxPack02`","auxPack03`","auxPack04`"}

So I could call

BeginPackage["testPack`", $auxPacks]

But didn't work. I also tried to create my own BeginPackage function as:

   myBeginPackage[packName_String]:=BeginPackage[packName,{"auxPack01`","auxPack02`","auxPack03`","auxPack04`"}]

But didn't work either.

Something similar this last try would be the best option to me. Any clue?

$\endgroup$
  • 1
    $\begingroup$ Could you elaborate on "didn't work" part, because your both solutions work for me. Problem with them is that $auxPacks or myBeginPackage needs to live in some context, which needs to be on $ContextPath when loading package. $\endgroup$ – jkuczm Dec 29 '14 at 13:15
  • 1
    $\begingroup$ You could create a "grouping package": BeginPackage["auxPack`",{"auxPack01`", ...}]; EndPackage[] and then call BeginPackage["testPack`", "auxPack`"] $\endgroup$ – jkuczm Dec 29 '14 at 13:18
  • $\begingroup$ Have you used any of suggestions, if so, maybe post selfanswer? :) $\endgroup$ – Kuba Nov 17 '15 at 7:34
  • $\begingroup$ @Kuba I will post $\endgroup$ – Murta Nov 17 '15 at 11:21
  • $\begingroup$ Related: mathematica.stackexchange.com/questions/115502/… $\endgroup$ – Szabolcs May 19 '16 at 11:07

Your Answer

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

Browse other questions tagged or ask your own question.