Tag Info

New answers tagged

1

Only last line in Module can be used for output (I mean without ';'). So put semicolon after EACH line except last one, the Print command will work anyway. Then it will work - just tested


0

Very strange! If you put an "a" after it works as expected: Module[{a}, a = Range[3]; ListPlot[a]] a It also works if you suppress the Module's output (but not ListPlot's): Module[{a}, a = Range[3]; Print@ListPlot[a]];


3

Source of the problem. The problem arises because the symbol t is localized two different times in two different ways, once in Module and once in the definition of pop. Below is a simplified example, with only a single function being solved for, but the same thing happens for OP's system. I print out the form of the solution sol and the definition of pop ...


3

Here is a method that is not exactly to your specification but which may serve you anyway. It uses a Symbol argument. Because a Symbol is passed it is automatically modified by Module and does not need the guesswork of $ModuleNumber etc. but it does need string conversion and cleanup. SetAttributes[printVal, HoldFirst]; printVal[s_Symbol] := Print @ ...


7

With this helper function: SetAttributes[partThread, HoldAll]; partThread[l___, rhs_] := Join @@ Replace[ MapIndexed[Append[#, First@#2] &, Thread[Hold[{l}]]], Hold[s_, i_] :> Hold[s = rhs[[i]]], {1}]; The following modification of LetL seems to work according to your specs: ClearAll[Let, let]; SetAttributes[{Let, let}, HoldAll]; ...


4

Yes it is possible, but in an indirect way. Here is one method: (I have to use screen shots to explain). Here is an example of myModule whose body prints a message to the screen, but the body is hidden This is done by making the implementation foo in this case, be in a separate cell, then utilizing cell->cell properties feature to close the cell from ...


5

I have checked it in versions 7.0.1, 8.0.4 and 10.0.1 (the Suggestion bar is turned off). The bug is present only in v.10.0.1, both v.7.0.1 and 8.0.4 return {"a"} after evaluating Names["Global`*"]: Moreover, if one adds a definition to the symbol a, the definition is not removed in v.10.0.1: Remove["Global`*"] Module[{a}, Information[a]; a = 1]; Symbol ...


2

If you need to preserve the definitions of a Symbol with exception(s) to some particular case(s) you should use Internal`InheritedBlock: f[a_, b_] := a + b; Internal`InheritedBlock[{f}, f[1, 2] := ab; Table[f[i, j], {i, 1, 2}, {j, 1, 2}]] f[1, 2] {{2, ab}, {3, 4}} 3


1

You can localize the symbol f, and then set f[1,2]=ab as part of the main body of the Block. Block[{f}, f[1, 2] = ab; Table[f[i, j], {i, 1, 2}, {j, 1, 2}] ]


0

Your question puzzled me for a long time. Let us have a look at your first question: Manipulate[ With[{f = Table[c[i], {i, n}], controls = Sequence @@ Table[{{c[i], 0}, -1, 1}, {i, n}]}, Manipulate[f, controls, Button["Random", Do[c[i] = RandomReal[{-1, 1}], {i, n}]]]], {n, {3, 4, 5}}] Why does it not work? You have a sliders that assign to c[1], ...



Top 50 recent answers are included