masterxilo
  • Member for 8 years, 9 months
  • Last seen more than a week ago
Version inconsistency with optional arguments: what if the default value doesn't match the pattern?
2 votes

In my opinion, Optional should just consistently not match when the default value does not match the pattern, period. Now we have nonsense like this: {}~MatchQ~{Optional[0., 0]} False You might ...

View answer
`Plus` wrongly applies `OneIdentity` to eradicate itself in `Plus[Power[_, 2] ..]`, unreproducible
Accepted answer
2 votes

As pointed out in comments, this is caused by Plus[x] is x Here are some workarounds Plus[Power[x, 2], Power[y, 2]]~MatchQ~Verbatim[Plus][Power[_, 2] ..] Plus[Power[x, 2], Power[y, 2]]~MatchQ~...

View answer
How to specify optional arguments that take functional values
2 votes

HoldPattern and Unevaluated work too. You can also remove the HoldAll once you made the definition if you like. ClearAll[f, g, h] f[HoldPattern@Optional[x_, RandomReal[]]] := x g[Unevaluated@Optional[...

View answer
What are the most common pitfalls awaiting new users?
2 votes

Association has HoldAllComplete attribute Association is not just another head denoting a special kind of list of rules or a certain kind of object. It has some properties that make querying it more ...

View answer
How to scope `Pattern` labels in rules/set?
2 votes

I think a third kind of behaviour would also be possible: it is debatable whether f@x_ = x, x_ -> x within Module[{x}, ... should not become f@x_ = x$123, x_ -> x$123 because then the sequence ...

View answer
How could I define a function as the solution of equations in Mathematica?
2 votes

I will give an elaborate answer because I think this is an area where Mathematica really shines ;) Let me digress. We know that, in general, an equation system defines a set of points as a function ...

View answer
How to make a Spherical Cow?
1 votes

You can do this using the discrete laplacian computed on the mesh by transforming along the thusly computed mean curvature flow. This operation is often called called smoothing in Geometry Processing. ...

View answer
Calling MATLAB from Mathematica
1 votes

For what it's worth, there also seems to be a way to integrate Mathematica into matlab (the other way around) using the "Mathematica Symbolic Toolbox for MATLAB--Version 2.0" http://ch.mathworks.com/...

View answer
why does Function have the HoldAll attribute?
1 votes

Inspired by Szabolcs answer and the discussion in the comments, here's another solution: EvaluateOwnValuesOnlyAndHold~SetAttributes~HoldAll EvaluateOwnValuesOnlyAndHold[expr_] := Hold[expr] /. ...

View answer
How to specify optional arguments that take functional values
1 votes

HeldOptional = Function[, HoldPattern@Optional[#1, #2], HoldRest] Remove[CurrentTime] CurrentTime[time_~HeldOptional~DateList[]] := {time, DateList[]}; Pause[1] CurrentTime[] c.f. How to write a `...

View answer
Fast `Shallow` for Associations?
1 votes

This formats Associations in the usual way: ShallowAssociation[x_Association] := RawBoxes@(({s = Shallow@Normal@x}~With~MakeBoxes@s)~ Replace~(RowBox[{"{", val_, "}"}] :> RowBox@{"\...

View answer
Fast `Shallow` for Associations?
1 votes

$r = Association["x" -> ConstantArray[0, {1000, 1000}]]; Shallow@($r /. Association -> Normal@*Association) performs well.

View answer
Mathematica is taking too much time in solving my problem
Accepted answer
1 votes

This numerical approach seems to work: Norm2[x_] := x.x; ConvertEquationsToLeastSquares[eqns : {__Equal}] := Norm2@Flatten[eqns //. { Equal[x_, y_, rest___] -> {Subtract[x, y], Equal[y, ...

View answer
How to write a `HeldOptional` variant of `Optional` that does not evaluate its second argument?
1 votes

This works: ClearAll[DontEvaluateInOptional]; DontEvaluateInOptional~SetAttributes~HoldAllComplete; DontEvaluateInOptional /: (h: Except[Optional])[l___, HoldPattern@DontEvaluateInOptional[b___], ...

View answer
`$ContextPath` different on first run
Accepted answer
1 votes

Looks like this is a problem with the Suggestions Bar https://mathematica.stackexchange.com/a/75284/6804 When I disable it, I get the same context path consistently. This is version 10.2. The ...

View answer
How symbol lookup actually works
1 votes

I think the following also fits the present discussion. Who shadows whom? When you run (*cleanup*) $Context = "Global`"; Quiet@Remove["temp`*", "Global`*"]; (*--*) Global`x = "global"; BeginPackage[...

View answer
Rewriting symbol context?
1 votes

Consider using strings: BeginPackage["foo`"]; Unprotect @@ Names["foo`*"]; ClearAll @@ Names["foo`*"]; f::usage = "sol=f[x,plist]"; Begin["`Private`"]; f[x_, plist_] := With[{y = Lookup[plist, "y"]...

View answer
How does Context work?
1 votes

I think every line or statement that you enter into the frontend is parsed separately, so, when you use a CompoundStatement there is only one parsing process, while there is one for each line when you ...

View answer
Is it possible to invoke the OEIS from Mathematica?
1 votes

Instead of relying on WolframAlpha data, you can query the database directly, preferable through the /internal data format, documented here: https://oeis.org/eishelp1.html One such page is: https://...

View answer
Strange problem with Derivative and BoxForm`MakeDerivativeBoxes
Accepted answer
1 votes

This has been filed and officially accepted as an issue: Thank you for contacting Wolfram Technical Support. I was able to reproduce the issue, and consequently, I filed a report with our ...

View answer
Visual Studio 2013 Mathlink addtwo
1 votes

All the former ML* functions now start with WS*, mathlink.h is now wstp.h. When you still get linker errors, try dragging and dropping the file "C:\Program Files\Wolfram Research\Mathematica\10.2\...

View answer
How to stop `Format` from evaluating when doing `Put`/`Export`?
0 votes

Export["file.m", FullForm@HoldComplete[Format[$hello, StandardForm]], "String"] works, but all operators will be eliminated because of FullForm: FullForm@HoldComplete[Format[$hello, StandardForm]*2] ...

View answer
Why does `Block` reset `Attributes`?
0 votes

This is not an answer as to why, wolfram-language-design wise, but to how: It seems Block[{x = new}, ...code...] effectively does the following: newValue = new; allValues = ...

View answer
VerificationTest for uncaught `Throw`?
0 votes

A VerificationTest with Outcome Error cannot be fixed by changing the expected-messages argument. This only applies to MessagesFailure Outcome (orange versus yellow cross, a bit hard to distinguish). ...

View answer
Programmatic formatting for Mathematica code - possible?
0 votes

t = CreateTemporary[]; Save[t, mySymbol]; Import[t, "Text"] applies some basic formatting to the definitions immediately and indirectly associated with mySymbol.

View answer
Interpolation and points of non-differentiability
0 votes

As suggested in a comment, you can use InterpolationOrder -> 1 and then fix the Indeterminate derivative. ClearAll[list, fint, dfint] list = Table[{j, Max[5, j]}, {j, 0, 15, 1}]; ListLinePlot@...

View answer
More issues Integrate, NIntegrate, FindRoot
0 votes

The documentation of FindRoot says FindRoot first localizes the values of all variables, then evaluates f with the variables being symbolic, and then repeatedly evaluates the result numerically....

View answer
Image3D with values outside of the range [0,1]
0 votes

You could use ListDensityPlot3D for visualization purposes instead. This also has the useful option "OpacityFunction"... IMO, you could also use Image3D and rescale the data only for display purposes....

View answer
How to convert Image3D object into Graphics3D object and vice versa?
0 votes

For Graphics3D -> Image3D: This answer: https://mathematica.stackexchange.com/a/33277/6804 gives an approach that rasterizes individual 2D slices at different heights and stacks them into a 3d image. ...

View answer
Is it possible to invoke the OEIS from Mathematica?
0 votes

Have a look at the output of a = Entity["IntegerSequence", "A004001"]; Grid[List@@@Normal@DeleteMissing@AssociationMap[a, EntityProperties@a]] Some of them have EntityProperty["IntegerSequence", "...

View answer
1
2