Hot answers tagged

29

Other answers have already suggested ways of querying options. There's no way of systematically generating a list of all string values, but it's not too difficult to put together a list of all of the values which are used by Wolfram Research in Mathematica itself. If you look in the various files in these locations: $InstallationDirectory/SystemFiles/...


19

Have you tried adding AppendTo[$Path, FileNameJoin[{$UserBaseDirectory, "ExtraPackges"}]] to the file FileNameJoin[{$UserBaseDirectory, "Kernel", "init.m"}] ? init.m is described here, under "more information".


16

The full form of ?@ is Information["@", LongForm -> False]. LongForm -> False means use the short form of Information, which calls Names["@"] (or a utility that both Information and Names use) to find the symbols which it should retrieve. Names interprets "@" as match one or more characters, but not uppercase letters So you are getting a short ...


14

I believe I would use: expr = Q1 a1 + Q2 a2 + Q3 a3 + Q4 a4 + Q5 a5 + Q6 a6 + Q7 a7 + Q8 a8 + Q9 a9 + Q10 a10 + Q11 a11 + Q12 a12 + Q13 a13 + Q14 a14 + Q15 a15 + Q16 a16 + Q17 a17 + Q18 a18 + Q19 a19 + Q20 a20 + Q21 a21 + Q22 a22 + Q23 a23 + Q24 a24 + Q25 a25 + Q26 a26 + Q27 a27 + Q28 a28 + Q29 a29 + Q30 a30 + Q31 a31 + Q32 a32 + Q33 a33 ...


13

These String items were directly read from the 10.0.2 Front End, including quite a few not listed elsewhere in this Q&A: {"AltKey", "ByteCount", "CellChangeTimesList", "CellCount", "CellStyleName", "CodeContext", "CommandKey", "ConnectedControllers", "ControlKey", "ControllerData", "ControllerState", "ControlsFontFamily", "ControlsFontSize", "...


13

Perhaps: using systemnames = Names["System`*"]; Select[systemnames, CurrentValue[#] =!= $Failed &]; CurrentValue /@ % // Short (* ==> {False, {FrontEnd`FileName[{$UserBaseDirectory, "Autoload"}], ... } *) for the System` context, and replacing System with the appropriate context name for other members of the list Contexts[]?


13

The only method I am aware of is to attempt an operation that requires administrator-level permissions and look for a General::privv message: Check[ (CreateDirectory @ #; DeleteDirectory @ #) & @ FileNameJoin[{$InstallationDirectory, "test"}]; True, False, General::privv ] // Quiet This should return True if it is run with administrator ...


10

To my understanding CurrentValue adds an alternative syntax to what Options and SetOptions provide for the frontend and notebooks. So in addition to what's documented I think Options[$FrontEnd] and Options[Notebook] would be a good starting point. These are what I usually consult when searching for something.


10

According to Oleksandr R. wmic can only be run by Administrators. Here is how you get the Serial on Windows. Import["!wmic bios get serialnumber", "Text"] To get CPU information Import["!wmic cpu get NumberOfCores, NumberOfLogicalProcessors/Format:List", "Text"] To get the MAC Address run. StringSplit[ StringReplace[ StringCases[Import["!ipconfig ...


9

To prevent your second invocation of SetOptions from resetting the value of sub-option "SymbolContextStyles", you need to set both "System" and "Global" sub-sub-option values at once: SetOptions[EvaluationNotebook[], "AutoStyleOptions" -> {"SymbolContextStyles" -> {"System`" -> RGBColor[211./255, 54./255, 130./...


8

xQ = Q1 a1 + Q2 a2 + Q3 a3 + Q4 a4 + Q5 a5 + Q6 a6 + Q7 a7 + Q8 a8 + Q9 a9 + Q10 a10 + Q11 a11 + Q12 a12 + Q13 a13 + Q14 a14 + Q15 a15 + Q16 a16 + Q17 a17 + Q18 a18 + Q19 a19 + Q20 a20 + Q21 a21 + Q22 a22 + Q23 a23 + Q24 a24 + Q25 a25 + Q26 a26 + Q27 a27 + Q28 a28 + Q29 a29 + Q30 a30 + Q31 a31 + Q32 a32 + Q33 a33 + Q34 a34 + Q35 a35 + Q36 ...


8

Replacement rules make this much easier, as Ymareth indicated. Make a list of rules like: r2 = {"x" -> Checkbox[True], "o" -> Checkbox[False], "u" -> Checkbox[3, {1, 2, 3}]}; Then apply these to the matrix m as: m/.r2 Note that this code is idiomatic Mathematica and imminently readable by anyone familiar with it. Nested For loops and ...


7

Basing on Sjoerds self answer, you were missing the subdirectories. I added that and the tr files (don't know if it was worth something). Probably I'm missing some others because this doesn't check box structures, but it does get a few extras fnames = FileNames[ "*.nb" | "*.tr", {FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd",...


6

Just to get an answer on record. As bobknight stated in the comments $InputFileName is bound to a string giving the full path name of the file being read when code loading operations initiated by Get, (<<), or Needs are in the process of loading. The file being loaded can make use this information, but the notebook requesting the load cannot (think of ...


6

You can use the Find and Replace command: ⌘+F on the Mac or Ctrl+F on a PC.


6

Not an answer but I just wanted to observe that the $RecursionLimit info box (whatever that is called) has a formatting error on my Mac: Update halirutan: When I set $RecursionLimit to say 30, then hover the symbol and click on the information $i$, I sometimes get more than only wrong formatting:


6

It may suit your purpose to use the Windows API function IsUserAnAdmin. It can be accessed through NETLink like this: Needs["NETLink`"] isUserAnAdmin = DefineDLLFunction["IsUserAnAdmin", "shell32.dll", "bool", {}]; isUserAnAdmin[] (* True if Mathematica was launched elevated, False otherwise *) It is also possible to to use the shell command whoami to ...


6

The only thing I could find very easily is the HWaddr of the network device that can be obtained by SystemInformation["Network", "IPAddresses"]


5

Using Nasser's expression code as an example: expr = Sin[x] + Cos[y] + z^3 + Exp[d] + h + 3 h^2 + 4 h^3 + Integrate[Exp[p], p] + D[Sin[m]^Exp[f], m]*Series[Sin[g], {g, 0, 3}] + 2 (E^a BesselK[0, 2 Sqrt[E^a]]) C[2]/D[Gamma[w], {w, 2}]; You might use: Variables @ Level[expr, {-1}] {a, d, f, g, h, m, p, w, x, y, z} To extract indexed ...


5

Note that while the accepted answer obviously answers the question it is also possible to set values of System` and Global` individually. CurrentValue[EvaluationNotebook[], {"AutoStyleOptions", "SymbolContextStyles"}] (* {"System`" -> {}, "Global`" -> {}, Automatic -> {}} *) So to set only System`: CurrentValue[EvaluationNotebook[], {"...


5

In addition to the other very useful answers, I'd like to start a collection of links to posts mentioning interesting CurrentValue items: The CurrentValue doc page Accessing the current style in a Graphics expression (e.g. CurrentValue["Color"])


5

You can do this programmatically by converting the expression to strings, replacing Qs with Rs and then converting it back to an expression. For example: expr := Q1 a1 + Q2 a2 + Q3 a3 + Q4 a4 + Q5 a5 + Q6 a6 + Q7 a7 + Q8 a8 + Q9 a9 + Q10 a10 + Q11 a11 + Q12 a12 + Q13 a13 + Q14 a14 + Q15 a15 + Q16 a16 + Q17 a17 + Q18 a18 + Q19 a19 + Q20 a20 + Q21 ...


5

Don't put symbols you don't want to show up in auto-completion into the Global` context. Use the same mechanism you would for a package. myfun; (* create in Global` *) Begin["MyPrivateInitContext`"] myfun[x_] := Module[{y=x^2}, y^2] End[] I noticed you are putting your function into the System` context. This seems like a bad idea. The System` context ...


4

ClearAll[x, y, z, d, h, p, m, f, g, a, w]; expr = Sin[x] + Cos[y] + z^3 + Exp[d] + h + 3 h^2 + 4 h^3 + Integrate[Exp[p], p] + D[Sin[m]^Exp[f], m]*Series[Sin[g], {g, 0, 3}] + 2 (E^a BesselK[0, 2 Sqrt[E^a]]) C[2]/D[Gamma[w], {w, 2}]; Cases[Variables[Level[expr, -1]], x_ /; AtomQ[x] :> x] (* {a, d, f, g, h, m, p, w, x, y, z} *)


4

As the Locale & Internalization guide page says $TimeZone is resettable. If the developers would foresee adverse effects I guess they wouldn't have documented it in this way. The only problem that I can see is that you have to take care that your system time is also set to GMT, otherwise real-time calculations (e.g., elevation of the sun as seen in ...


4

Perhaps there's a better way than using Reduce three times, but it seems to me that the computations to figure out the range of each variable will have to be done somehow. Reduce does that. This will work on such simple inequalities as in the OP's example: And @@ (First@Reduce[a == b + c && a >= 2 && b <= 10 && c == 5, #] &...


4

I don't know about temporary values, but if you want to monitor the progression of Nest you could use the following: intensiveCalculation[x_] := (Pause[0.5]; x + 1) Nest[(PrintTemporary[#]; #) &@ intensiveCalculation[#] &, 1, 5]


4

{time, mean, std} = Transpose[Import["C:\\Users\\...\\Downloads\\MEANSDVALUES.xlsx"][[1]]] (* use the appropriate directory for your file *)


4

Clear[GetVariables] SetAttributes[GetVariables, HoldFirst]; GetVariables[expr_, f_:Identity, excludedContexts:{__String}:{"System`"}]:= Cases[Unevaluated[expr], a_Symbol/;!Or[ MemberQ[excludedContexts, Context[a]], MemberQ[Attributes[a], Locked | ReadProtected] ] :> f[a], {0, Infinity} ]//DeleteDuplicates It is used like ...


4

There is a missing semicolon just behind the end of the outer For, just before the x, corrected below. addChekboxesTable[x0_] := Module[{x = x0}, For[i = 1, i <= Length[x], i++, For[j = 1, j <= Length[x[[i]]], j++, If[x[[i, j]] == "x", x[[i, j]] = Checkbox[True];] If[ x[[i, j]] == "o", x[[i, j]] = Checkbox[False];] If[ x[[i, j]]...



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