Linked Questions

13
votes
1answer
2k views

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 <...
1
vote
1answer
368 views

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

Here's a minimal working example of a problem I'm having: ...
1
vote
1answer
99 views

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. ...
0
votes
1answer
43 views

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 ...
0
votes
1answer
58 views

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 ...
1
vote
0answers
57 views

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.
0
votes
0answers
36 views

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 : <...
528
votes
19answers
132k 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 ...
179
votes
3answers
39k views

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 ...
68
votes
7answers
4k views

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 ...
48
votes
7answers
71k views

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? ...
52
votes
2answers
2k views

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 ...
17
votes
5answers
2k views

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 ...
21
votes
3answers
2k views

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 ...
26
votes
1answer
2k views

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, ...

15 30 50 per page