Linked Questions

603 votes
19 answers
157k views

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
124 votes
7 answers
18k views

Struct equivalent in Mathematica?

I really miss having something like a struct in Mathematica. I know of (and regularly use) a couple of programming techniques which feel like a ...
Cassini's user avatar
  • 5,626
75 votes
6 answers
7k views

Does Mathematica have advanced indexing?

I have two $M \times K$ arrays $L, T$ where I would like to set all the elements in $L$ to zero whenever the corresponding element of $T$ is greater than 15. The ...
Brian B's user avatar
  • 1,553
83 votes
3 answers
9k views

Metaprogramming in Mathematica

Being functional, and having no "quotation", i.e. essentially treating data and programs semantically same, Mathematica seems naturally capable of doing metaprogramming. But could anyone construct a ...
user13253's user avatar
  • 8,656
20 votes
4 answers
3k views

Pure Functions with Lists as arguments

Assuming I have two function: example 1: add[{x_, y_, z_}] := x + y - z add[{1, 3, 5}] If use pure function,I know I can write it as : ...
matrix42's user avatar
  • 7,180
19 votes
2 answers
2k views

Lexicographic ordering of strings in Mathematica

I recently realized that Mathematica seems incapable of comparing strings in the "normal" expected lexicographic order. Indeed, for some simulations, I need to process text directly, without fiddling ...
Jérémie's user avatar
  • 433
8 votes
1 answer
2k views

Is there anything like a C pointer (or returning a reference) in $Mathematica$?

I want to do in Mathematica what the following does in C. ...
Andrew Cheong's user avatar
10 votes
1 answer
292 views

Error Using Sow in DensityHistogram with ColorFunction

To find the color values used in a plot, I was using Sow as shown here: ...
Jens's user avatar
  • 97.7k
6 votes
3 answers
232 views

Map Input A B C to MyProduct[A,B,C] (NOT to Times[A,B,C])

In writing my own (noncommutative) product I want to avoid typing redundant symbols like A.B.C or A**B**C, I just want to type <...
NoEscape's user avatar
  • 842
8 votes
1 answer
184 views

Recommendations about modifying usage of built-in symbols

In my package, I use some of the built-in Mathematica symbols in non-canonical ways. Right now, I use them as Options or ...
QuantumDot's user avatar
  • 19.7k
0 votes
2 answers
123 views

How to put the result(and its specified variable) to clipboard

I have a such custom function to do some complicated thing: customFun[str_] := Defer[StringJoin["abc",ToString[#]]&@*StringLength][StringDrop[str,{1,-1,2}]] ...
yode's user avatar
  • 27k
2 votes
0 answers
72 views

Set-generating macro unexpectedly reaches recursion limit

One moment I decided to assign symbolic names to all special spaces since they all look the same when put literally in FrontEnd editor, more or less like "" or <...
akater's user avatar
  • 1,540
1 vote
0 answers
65 views

Wrapping an association with a specialization of the buildin `Set` (=) function?

I want to wrap some association data into a dedicated symbol (S by example) ...
Picaud Vincent's user avatar