Linked Questions

13 votes
1 answer

When to use @@@ vs. /@ [duplicate]

So much thanks to Szabolcs in improving sequence.. for complete explanation. I am so glad to read all explanation which fundamentally remove the problem. But in number 4 of its explanation pointed to <...
Unbelievable's user avatar
  • 4,847
1 vote
1 answer

Misunderstanding the difference between Map Apply (@@@) and Map (/@) [duplicate]

Here's a minimal working example of a problem I'm having: ...
Shane's user avatar
  • 1,003
1 vote
1 answer

I keep writing functions like this one: subtract[{a_, b_}] := Subtract[a, b] [duplicate]

(Edited to provide an example) Recently I have found myself writing silly functions like the following, which is just a new arity of Subtract in which the arguments are inside a list. ...
Ralph Dratman's user avatar
0 votes
1 answer

Struggling to Apply "Differences" [duplicate]

It looks like the following code should work, and allow it spits out error messages saying I have too many arguments, the code spit out after the error message looks like exactly what I want to ...
Elem-Teach-w-Bach-n-Math-Ed's user avatar
0 votes
1 answer

Problem with Apply [duplicate]

I have am trying to obtain the average of the distance from the mean radius for each shot in a group of shots at a target. I am having problems with the very last line. The output of the last line ...
Steven Anderson's user avatar
1 vote
0 answers

Simple question about compared Map (/@) against Apply first level (@@@) [duplicate]

Does the function Map (/@) is equivalent to Apply to first level (@@@) ? he way that I see this head functions are that both are equivalent. Please, comment if they have a fundamental difference.
Jose Enrique Calderon's user avatar
0 votes
0 answers

Understand the notion of level with apply [duplicate]

There is something I don't understand with the notion of levels with apply. I take this example : Apply[f, {{a, b, c}, {d, e}}, {2}] Mathematica answers me : <...
StarBucK's user avatar
  • 2,164
602 votes
19 answers

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 ...
205 votes
3 answers

Alternatives to procedural loops and iterating over lists in Mathematica

While there are some cases where a For loop might be reasonable, it's a general mantra – one I subscribe to myself – that "if you are using a ...
Mr.Wizard's user avatar
  • 271k
75 votes
7 answers

Functions vs. patterns

Every time I define a new function, I wonder which construct I should use: true functions obtained by using Function, or rule-based syntax. For example, these are ...
David's user avatar
  • 14.9k
64 votes
8 answers

Assign the results from a Solve to variable(s)

I understand Mathematica can't assign the results of a Solve to the unknowns because there may be more than 1 solution. How can I assign the 4 values of following result to variables? ...
stevenvh's user avatar
  • 6,856
53 votes
2 answers

Head and everything except Head?

I have been working on picking expressions apart using Head and Part and encountered a little mystery. Consider the canonical ...
Reb.Cabin's user avatar
  • 8,661
18 votes
5 answers

Iterate until condition is met

I want to find the first 5 prime numbers of the form $n^6 + 1091$. I have used this code: Timing[Select[Table[n^6 + 1091, {n, 10000}], PrimeQ, 5]] Which gives ...
nickjamesuk's user avatar
23 votes
3 answers

When must I use the Return function?

In a comment to my answer to this question, QuantumDot asks, "Where can I find more information on when I must use the 'Return' function?". I found this too deep a question to be answered by leaving a ...
m_goldberg's user avatar
  • 108k
29 votes
1 answer

Two ways to map a function on a list: Which one is faster?

There are two ways to make a function listable on the list: Use Map or use SetAttributes. My question is, which one is faster, ...
Nam Nguyen's user avatar
  • 1,751

15 30 50 per page