# Tag Info

13

I believe it does work, just not how you expect. :-) From the documentation for PutAppend: Note that there are no quotation marks around filename in the first line. It is not made particularly clear but you can use this syntax with >>>: Range[10] >>> file.txt Which outputs to a file named file.txt directly. This is a special and ...

13

The output from Information[] gets sent to the $Urgent stream. Here is how you can capture it: infoFile = OpenWrite["info.txt", FormatType -> OutputForm, PageWidth -> Infinity] Block[{$Urgent = infoFile}, Information["DSolve", LongForm -> False] ] Close[infoFile] Note that I used PageWidth->Infinity. This results in possibly (?) cleaner ...

10

The question is, what do you want to do with the output. The output of Position is in a form so that it can directly be used with Extract list = {a, b, a, a, b, c, b}; pos = Position[list, b]; Extract[list, pos] (* {b, b, b} *) For this simple example, it is a bit useless because we already know, that on all positions pos we have a b in list. ...

10

I consider this a bug in the front end. Very odd it is, that not all forms eat up the first result. Consider this simple example m = {1}; MatrixForm@m MatrixForm@m which gives 2 outputs as expected. If we look on the traffic between kernel and front end, then we see, that the kernel indeed sends 2 outputs back. No matter which kind of form we use: FE ...

9

There are several issues here. You need to "inject" the symbol name into the expression using With (or similar) to prevent trying to make an assignment to ToExpression["col" <> ToString[i]]. Further, you've got spurious Background -> expressions which do not belong. (I also use Symbol in place of ToExpression.) That gives us: ...

7

As Yves already mentioned, you can easily create and edit notebooks through Mathematica commands. A start would be this tutorial, which you can find in the Documentation Center under tutorial/ManipulatingNotebooksFromTheKernel Here is a short example printing the i values into a new notebook: nb = CreateDocument[]; For[i = 1, i <= 10, i++, ...

7

I have found one solution, using a temporary file:- streams = AppendTo[$Output, OpenWrite[]]; Module[{}, Print[Plot[Sin[x], {x, 0, 2 Pi}]]; a = 123]; Close@Last@streams;$Output = Most@streams; printoutput = ReadList@First@Last@streams

7

(This answer doesn't include how to make it fullscreen, I can't manage to get any window at all to fullscreen without going through my window manager) With DisplayFunction -> (CreateDialog[#, WindowMargins -> {{1, Automatic}, {Automatic, 1}}]&) you can get it in the top left corner, however it will be on the main display. From WindowMargins: ...

7

If you examine the Cell expressions (select the cell and hit ctrl-shift-E) you can see that in the first case the lines are separated by \n whereas in the second case [IndentingNewLine] sneaks in (I pasted the second case and hit return between the lines as it pasted as a single line). It would appear that [IndentingNewLine] doesn't count as an input ...

6

I'll assume that you want to echo any literal Set operation that occurs in input, even if it is not on a line by itself. $Pre This may work for you:$Pre = Function[ main, Unevaluated[main] /. Set -> Function[, Print@HoldForm[# = #2]; # = #2, HoldFirst], HoldAll ]; Now: {a = 2 + 2, b = 10/2, c = Sqrt[9]}; a = 4 b = 5 c = 3 ...

5

One way to do this is to define the solution as sol = Solve[b^2 + b*z + 1 == 0, b][[1]]; and then plot using the strategy suggested in the Help file for Solve, which replaces the variable in the rule (in this case b) with the desired solution: Plot[b /. sol, {z, -10, 10}, PlotRange -> All]

5

It's just not always true that $(R^3)^{1/3} = R$. How about $R=i$, for example? N[(I^3)^(1/3)] (* Out: 0.866025 - 0.5 I *) If you expect this, you might have more luck with the real-valued CubeRoot function. For example: FullSimplify[CubeRoot[R^3]] (* Out: R *)

5

You can temporarily redefine Print, like so: fun[] := Module[{}, Print[Plot[Sin[x], {x, 0, 2 Pi}]]; a = 123] list = {}; Block[{Print = AppendTo[list, {##}] &}, fun[]] Now list contains everything that was printed. (Of course in a practical application you'd probably want to do something smarter than an inefficient periodic AppendTo) If you still ...

5

The following works for me output = OpenWrite["C:\\Users\\Mike Croucher\\outtest3.txt", FormatType -> OutputForm]; $Output = output Print["hello"] Close[output]; I get the word 'hello' in outtest3.txt. However, the following does not work output = OpenWrite["C:\\Users\\Mike Croucher\\outtest4.txt", FormatType -> OutputForm];$Output = output ...

5

You could use the function JWindow from the JVMTools Mathematica add-on package. It returns the JFrame object and the JPanel object, and you can further process these objects, as explained on the page JVMTools window functions (scroll down to the section "Further Processing of the Java Objects"). For example: ...

4

Presuming you only want to this special output to come from computations that bind a variable to the value of the computation, here is one way it can be done by $Pre and$Post: SetAttributes[saveSet, HoldAll]; saveSet[form : Set[var_, _]] := (lastSet = ToString@Unevaluated@var; form); saveSet[form : ___] := (lastSet =.; form) $Pre = saveSet;$Post = ...

4

When handling symbols like you do, I find it best to avoid converting from and to strings. This is typically needed in other languages to do meta-programming, however due to Mathematicas philosophy being that everything is an expression, meta-programming can be accomplished simply by holding evaluation order. Here is a simple implementation of your ...

4

As mentioned in the comments, to search for multi-letter palindromes, two underscores are needed as described in the help for string patterns: Palindrome[] := DictionaryLookup[y__ /; (y == StringReverse[y])] Now, Mathematica is probably not good enough to come up with lyrical palindromes.

3

Why not this? x = {1, 2, 3}; y = {4, 5, 6}; z = {7, 8, 9}; output = Table[x[[i]] + y[[j]] + z[[k]], {i, 1, 3}, {j, 1, 3}, {k, 1, 3}] sfile = OpenWrite["test.txt"] For[i = 1, i <= 3, i++, For[j = 1, j <= 3, j++, For[k = 1, k <= 3, k++, str = ToString[{x[[i]], y[[j]], z[[k]], output[[i, j, k]]}]; WriteString[sfile, StringReplace[str, "{" | "}" ...

3

sfile = OpenWrite["~/Desktop/test.txt", FormatType -> StandardForm] For[i = 1, i <= 3, i++, For[j = 1, j <= 3, j++, For[k = 1, k <= 3, k++, Write[sfile, x[[i]], " ", y[[j]], " ", z[[k]], " ", output[[i, j, k]]]]]] Close[sfile] seems to work. I used FormatType -> StandardForm and added the spaces by hand. I'm sure there are ...

3

With $PerformanceGoal set to "Quality" by default, Histogram will generate tooltips for all the bars, which are dynamic objects. You can disable this with the option PerformanceGoal -> "Speed". With[{data = RandomVariate[NormalDistribution[], 1000]}, FreeQ[InputForm@Histogram[data, PerformanceGoal -> #], Tooltip | DynamicBox] ]& /@ {"Speed", ... 3 A self-destructing cell that creates a self-destructing button which deletes all cells generated by Print: (credit: Sasha, jVincent and Yves Klett for the ideas in answers/comments in the linked Q/As) Print[Button["Delete Print-generated cells & disappear", NotebookFind[SelectedNotebook[], "Print", All, CellStyle]; NotebookDelete[]]]; ... 3 I suspect that this has something to do with the code that produces the InputForm cell tags, or rather tagged cells. In addition to the last tagged cell replacing the prior ones you can observe strange behavior when combining CellPrint and InputForm: InputForm[1 // CellPrint] InputForm[2 // CellPrint] InputForm[3 // CellPrint] 1 Out[1]//InputForm= 2 ... 3 You print by having a Print[] on the expression you want to print. End all other statements with ;. fooToPrint = bar[...]; Print[fooToPrint]; fooNoPrint = bar[...]; e.g., a = 1 + 2; Print[a]; b = 3 + 4; a = b; Print[a]; 3 Comments do block the outputs when using %, but to avoid the weird effect you found adding space after the CompoundExpression (;) I suggest you to put the semicolon after the comment. In this way the comment block % independently of blank spaces. a; b; c; (6 - 3) (*comment*); (5 - 3) (*comment*); (4 - 3) (*comment*); {Out[-3], Out[-2], Out[-1]} {a,b,c} 2 You can also use FlipView Row[Table[FlipView[Style["x", 50, Background -> #] & /@ {Gray, Green, Red}], {5}]] 2 Something along these lines? SetAttributes[f, HoldAll]; f /: h_?headPredQ[b___, f[arg_], a___] := With[{res = h[b, arg, a]}, res /; Hold[res] =!= Hold[h[b, arg, a]]]; Format[f[arg_]] := Defer[arg]; headPredQ[h_] := MemberQ[Attributes@h, NumericFunction]; EDIT New version that contemplates the third case I had forgot (thanks @MichaelE2). This compares ... 2$PrePrint = RawBoxes[ToBoxes[#] //. FractionBox[x_, y_] :> RowBox[{If[Head[x] === RowBox, RowBox[{"(", x, ")"}], x], "/", If[Head[y] === RowBox, RowBox[{"(", y, ")"}], y]}]] &; Then every fraction in your output will be of the form x/y. For example:

2

Assuming you want your labels inserted into a 2D Graphic, it can be done like this: With[{n = 3}, Module[{pts, lbls}, SeedRandom@1; pts = RandomReal[1., {n, 2}]; lbls = Table[ Text[Row[{Subscript[θ, i], "/\[ThinSpace]2"}, "", BaseStyle -> {"TR", 10}], pts[[i]]], {i, Range @ n}]; Framed @ Graphics[lbls]]] ...

2

Table[{a, b, c, GCD[fun1[c^a], fun1[c^b]], GCD[fun2[c^a], fun2[c^b]]}, {a, 1, 3}, {b, 1, 3}, {c, 1, 3}] // TableForm and with the final differences: Table[{a, b, c, x = GCD[fun1[c^a], fun1[c^b]], y = GCD[fun2[c^a], fun2[c^b]], x - y}, {a, 1, 3}, {b, 1, 3}, {c, 1, 3}] // TableForm You can reformat the table by Flatten[Table[{a, b, c, x = ...

Only top voted, non community-wiki answers of a minimum length are eligible