Tag Info

Hot answers tagged

16

I see no mention of the new-in-10 PositionIndex in the other answers, which takes a list (or association) of values and returns a 'reverse lookup' that maps from values in the list to the positions where they occur: In[1]:= index = PositionIndex[{a, b, c, a, c, a}] Out[1]= <|a -> {1, 4, 6}, b -> {2}, c -> {3, 5}|> It doesn't take a level ...


13

Good News Everyone! Two-parameter syntax for Fold and FoldList has been (silently) implemented! Taliesin Beynon informs me that this was implemented in 2011, so check your older versions as well. Using version 10: Fold[f, a] FoldList[f, a] f[f[f[1, 2], 3], 4] {1, f[1, 2], f[f[1, 2], 3], f[f[f[1, 2], 3], 4]} And the held expression example: ...


8

I'm the one inside the company who suggested RightComposition (and pushed for syntax for Composition and RightComposition). I'm sympathetic to your need, and have wanted the same thing once or twice myself. Given that not much /* and @* code has been written yet, I think it is certainly possible we could have /* parse to LeftComposition. I'm not sure what ...


6

Using this site as my rubber duck and attempting to answer my own questions: (1) Reason for existing behavior One may want to be able to do this: heldRow = HoldForm @* Row @* List; (* version 10 syntax *) x = 7; Block[{x}, heldRow[x + x + x, x^2*x^3] ] 3 xx^5 (* proposed behavior would yield: x+x+xx^2 x^3 *) My counterargument: this ...


6

It comes down to the DRY principle: The DRY principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." The content management system Wordpress doesn't use object oriented paradigms and so for that reason it looks exactly like your code. Tens of thousands of lines of code like this. ...


3

Initial problem There is, in my opinion, nothing wrong with "multidependences" in the way I think you mean, but there is a more fundamental problem here (I believe). Consider these definitions: w[b_, x_] := fixed + b[x] u[w_, b_, x_] := Sqrt[w[b, x]] I presume that you expect to call u with three arguments and have it in turn call w but this does not ...


3

I find using Module the easiest way to keep track of things when it comes to these kinds of situations. plot[x_, s_] := Module[{b, w, c, ua, ub}, b = 10 x; w = s + b; c = x^2; ua = w - c; ub = w - c^2; Plot[{ua, ub}, {x, -5, 5}]] plot[randomVar, 5]


3

This behavior is present in both version 7 and version 10 (Windows). Illustrated: IdentityMatrix[2] // matrixform {{1, 0}, {0, 1}} // matrixform There is a difference between {{1, 0}, {0, 1}} and (the evaluated form of) IdentityMatrix[2]: the latter is a packed array. {{1, 0}, {0, 1}} // Developer`PackedArrayQ IdentityMatrix[2] // ...


2

I can't explain this strange behaviour of GridBox. But replacing it with Grid I get the desired output (also with a.a // matrixform) matrixform[mat_] := TraditionalForm[ DisplayForm[ RowBox[{StyleBox["[", SpanMaxSize -> \[Infinity]], Grid[mat], StyleBox["]", SpanMaxSize -> \[Infinity]]}]]]; To align the numbers properly use Grid[mat, ...


2

Clear["Global`*"] g[x_] := x^3 f1[x_] := g[x^2] f2[x_] := g[x^3] Definition@f1 f1[x_] := g[x^2] FullDefinition@f1 f1[x_] := g[x^2] g[x_] := x^3 Head@f1 Symbol Information["f*"] a[1] = 1; a[2] = 2; ?a DownValues@a UpValues@a


1

I've actually managed to answer it myself - will answer here if it's any good to others; Ebound[r_] = Piecewise[{{Eb1[rn, 14400] /. x, r < rn}, {Eb1[r, 14400] /. x, r > 0}}]; Plot[Ebound[r], {r, 0, ro}, PlotRange -> Automatic] this gives the expected behaviour;



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