Rcpp attributes: A simple example ‘making pi’  November 20, 2012
We introduced Rcpp 0.10.0 with a number of very nice new
features a few days ago, and the activity on the rcpp-devel
mailing list has been pretty responsive which is awesome.  But
because few things beat a nice example, this post tries to build
some more excitement. We will illustrate how Rcpp attributes
makes it really easy to add C++ code to R session, and that that
code is as easy to grasp as R code.  Our motivating example is
everybody's favourite introduction to Monte Carlo simulation:
estimating π. A common method uses the fact the unit circle has
a surface area equal to π. We draw two uniform random numbers x
and y, each between zero and one. We then check for the distance
of the corresponding point (x,y) relative to the origin. If less
than one (or equal), it is in the circle (or on it); if more
than one it is outside. As the first quadrant is a quarter of a
square of area one, the area of the whole circle is π -- so our
first quadrant