Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Possible Duplicate:
Functions vs. patterns

I thought about describing the context in which I faced this problem, but I figured it is general enough and clear enough to pose it as it is.

What is the difference between the two following definitions:


Under what circumstances will the two behave differently? Is any of them preferable as a general practice?

share|improve this question

marked as duplicate by Leonid Shifrin, Yves Klett, Mr.Wizard Dec 4 '12 at 11:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

@LeonidShifrin well, there are the much better answers! –  Yves Klett Dec 4 '12 at 11:30
@YvesKlett At the time that one was asked, we had a lot of energy since we were only out there for a week :) –  Leonid Shifrin Dec 4 '12 at 11:31
@LeonidShifrin question on best practice: since my answer is now quite redundant and I am voting to close, should I delete the answer? –  Yves Klett Dec 4 '12 at 11:36
@YvesKlett Since the question is likely going to be closed,I think that does not matter much. –  Leonid Shifrin Dec 4 '12 at 11:37
@LeonidShifrin True that. Googling with site:mathematica.stackexchange.com added to the search terms is often better. –  Sjoerd C. de Vries Dec 4 '12 at 12:52

1 Answer 1

Very short answer on one relevant difference (probably much better ones will appear):

A pure function like g will be faster performance-wise, because it gets rid of all the overhead (e.g. pattern matching) involved in the definition of f.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.