Finding expected values of random variables in R
Today, I answered a StackOverflow question where the author was implementing a function for finding the mean of a continuous random variable, given its probability density function (PDF).
In the process of writing up my answer, I ended up applying some functional programming techniques (specifically function factories).