FJRA
• Member for 9 years, 11 months
• Last seen more than a week ago

Based on that outdated notebook, I did the following function: VennDiagram2[n_, ineqs_: {}] := Module[{i, r = .6, R = 1, v, grouprules, x, y, x1, x2, y1, y2, ve}, v = Table[Circle[r {Cos[#], Sin[#...

If you want to keep the rows and your preferences of ordering is first ascending, second descending and third ascending, you can use SortBy: SortBy[data, {#[[1]],-#[[2]],#[[3]]}&]

When I don't want to use a wrapper to see how much time is used, I use AbsoluteTime[]: timming=AbsoluteTime[]; calculations... timming=timming-AbsoluteTime[]; Something I like about AbsoluteTime[] ...

With ReplaceAll and Increment you can do it: i = 1; {a, b, {c, d}, e, {f, {g, h}}} /. p : Except[List]?AtomQ :> {i++, p} {{1, a}, {2, b}, {{3, c}, {4, d}}, {5, e}, {{6, f}, {{7, g}, {8, h}}}} ...

The best you can do it is to speed up your function. Your calc is using a replace, but it's better if you use With: calc[a_, b_, c_, d_, e_, f_] := With[{Q = (8000000 \[Pi] Sin[ 1/2 ArcCos[ ...

Try using Table, assuming x is an array of values you could try: matrix = Table[{xi, y1[xi], y2[xi], ..}, {xi, x}] Table will "do the For loop" while building matrix, in this case xi will take each ...

Your arrayToBeFilled doesn't change in the global kernel but in the parallel kernels. The way you should do your parallel is this: arrayToBeFilled = Parallelize[Table[If[arrayA[[i]] <= 0, arrayA[[...

"Antarctica" is part of CountryData, but it is not returned by CountryData[All], and it's only returned by CountryData["Continents"]. If you want quick graphics (including country borders) you should ...

If you take out Method -> {"ShrinkWrap" -> True} it works as I think you expect.

I would prefer to use the "GeoImage" styling, because you can use other projections when using it. Let's say you have data for the whole world in a matrix: data = Table[ Sin[x Degree] Sin[y Degree]...

I think avoiding ToExpression is important, so here is a solution using Symbol: MapThread[With[{var = (Clear[#1]; Symbol[#1])}, var = #2] &, data] I use Clear to be sure that the symbol has not ...

It could be something like this? outersquare = {{-1, -.8}, {1, .8}}; innersquare = outersquare/10. + {-.1, 0}; corners[sq_] := {sq[[1]], {sq[[1, 1]], sq[[2, 2]]}, sq[[2]], {sq[[2, 1]], sq[[1, 2]...

You can do something like this: resetMessages[symbol_] := With[{mysymbol = symbol}, Unprotect[$MessageList];$MessageList = DeleteCases[$MessageList, HoldForm[MessageName[mysymbol, _]]]; ... View answer Accepted answer 9 votes My proposition: list = RandomReal[1., {100000, 3}]; newlist = Transpose[{Sequence @@ Transpose[list], list[[All, 2]] list[[All, 3]]}]; A little benchmark using other answers: In[51]:= list = ... View answer 8 votes Would this do the trick? selectWords[chars_, min_, max_] := Module[{charsset = Union[chars], charstally = Tally[chars], baselist, baselistchars, baselistpicks}, baselist = ToLowerCase[... View answer 7 votes Sometimes I define my pattern using a tolerance value to consider zero: tolerance = 10.^-15; F[A___, zero_ /; Abs[zero] <= tolerance, B___] := 0; As said before, using Chop is possible too (and ... View answer 7 votes Maybe option LocatorAutoCreate -> True is what you need, it is documented in the help. This is the example shown in the Manipulate tutorial: Manipulate[Graphics[Polygon[pts], PlotRange -> 1], {... View answer 7 votes You are looking for a variable transformation, so I would do something like (if you know that y is not 0): x/(y*z) /. z->w/y In that way, you get rid of z, and if there is any other place in the ... View answer Accepted answer 6 votes You can use DeleteCases, Cases, Select, etc. Here a couple of examples: DeleteCases[lis, s_?StringQ /; StringMatchQ[s, DigitCharacter..~~"-"~~DigitCharacter..]] Select[lis, !StringMatchQ[#, ... View answer Accepted answer 6 votes Expanding a bit @jose answer, instead of using the GeoStyling directive, maybe using the plot data is better. Let's generate a random sample, but with the same format as yours: data = Join @@ Table[{... View answer Accepted answer 6 votes After your last comment, maybe you should assing the value of cyL[change[x]] to another variable in the dynamic, and use it outside. Something like this: View answer 6 votes This is a nice problem. I get this solution: Initialization: start = RandomReal[1, {12, 2}]; end = With[{dx = 0.1, dy = 0.1}, {{-dx, 1 + dy}, {.25 - dx/4, 1 + dy}, {.75 + dx/4, 1 + dy}, {... View answer 5 votes Using @Sjoerd idea of Clipping, maybe you could use too Rescale. Something simple could be a wrapper to rescale every point inside a Graphics: rescale[things_] := Module[{points = Cases[things,... View answer 5 votes Another approach using Split: removeLonely[list_, tol_: 1] := Join @@ DeleteCases[Split[Sort[list], Abs[#2 - #1] <= tol &], {_}]; I also included a tolerance parameter that defaults to 1. ... View answer 5 votes After reading the answers, this is one way more to do it (maybe too simple): a[[4 ;; 6]] = ConstantArray[{1, 2, 3}, 3]; Thinking in it, you can do your own simple Set: Attributes[simpleSet] = {... View answer 5 votes There is one case else to be added (how rich is Mathematica!): Max[Replace[l, Indeterminate -> -Infinity, {1}]] // AbsoluteTiming {0.639738, 99.9987} which is comparable (in my machine) to: Max@... View answer 4 votes That's common in more than one case, for example, python also intercepts signals, but usually it exits, unless it is in interactive mode, where Ctrl C will stop the current computation but not exit ... View answer 4 votes Using With might do the trick too: ClearAll[a]; With[{paramToVary = a, paramValues = Range[0, 1, .2]}, Table[a, {paramToVary, paramValues}] ] {0., 0.2, 0.4, 0.6, 0.8, 1.} View answer Accepted answer 3 votes That's an old design: if the input matches exactly the standard name, it will return the entity by itself. If the input is not a valid standard name, it will try to find the possible entities the ... View answer 3 votes Your Which version might be improved. In general built-in functions do not return$Failed, but themselves, so, to do it, you usually need to use Conditional expressions. This might be written in many ...