4
$\begingroup$

I often use structures similar to the "func" below, however I would like to be able to "hide" the function definitions (similar to cell grouping using a group opener). I think an inline cell is the answer but I have had no success in implementing it.

func[this_][arg_] := this =Module[{f, g},
   f[x_] := x Sin[x];
   g[x_] := x^2 + x + 1;
   <|
     "x" -> arg,
     "f" :> f[this["x"]],
     "g" :> g[this["x"]]
   |>];
$\endgroup$

1 Answer 1

4
$\begingroup$

however I would like to be able to "hide" the function definitions

I recommend using Mathematica's Eclipse workbench for these things. I am now switching all my development to it, since it also has a very nice debugger and many more advantages, too many to list here. It has all the features of the notebook in terms of code completion, etc.. plus more.

Do all you code writing inside the workbench as .m files, and use the notebook .nb file only to make the main calls to your functions, ie. as driver or for testing and other small code for trying things out.

Here is an example doing what you want inside the Wolfram workbench. There is a small + mark next to each function. If you click on it, it hides the code of the function. Click again, it open the code again.

enter image description here

$\endgroup$
1
  • $\begingroup$ Comments are not for extended discussion; this conversation has been moved to chat. $\endgroup$
    – Kuba
    Oct 4 at 16:30

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.