
October 2009
August 2009
April 2009
March 2009
December 2008
October 2008
September 2008
August 2008
July 2008
June 2008
Well, I’ve been a bad blogger lately, lots of awesome stuff going in in the world of Ingrid. I’m now working at Gnip. I’ve gotten the chance to do some really cool stuff there, having a great time for sure!
In any case, here’s a little snippet of something I wrote. In Computer Science, recursion is a major conceptual hurdle to get through. Once you master it in school, you sadly may or may not ever see it again. Well, I was fortunate enough to need the beauty of recursion recently.
Say you are trying to calculate the date of the first Sunday in September of 2008. You know that the first day of September is September 1st. The following recursive function in PHP will take the parameters and return the day part of the date. For instance,
echo addDay(“9″, “1″, “2008″, “0″);
This will return 7; the first Sunday in September of 2008 is, indeed, September 7, 2008. Here is the function: