Hi, On 02/10/2011 01:57 PM, Chandrashekar Babu wrote: > On 10/02/11 11:23 AM, Vinod Parthasarathy wrote: > >> Here's one way of writing factorial in Haskell. >> >> factorial 0=1 >> factorial n=n*factorial(n-1) > > And here's the pythonic way: > factorial = lambda n: n and n*factorial(n-1) or 1 > > Succinct :-) > > Or even better: > from math import factorial # Batteries included! > print factorial(6) > > The Haskell version is also neat (more readable IMO).
... just thought I'd share this since we were slowly drifting into the functional programming, here is one series of articles I read back-to-back in one go when I stumbledupon'd[1] it: http://devlicio.us/blogs/christopher_bennage/archive/2010/09/06/what-is-functional-programming.aspx cheers, - steve [1] www.stumbleupon.com (also see my sig) -- random spiel: http://lonetwin.net/ what i'm stumbling into: http://lonetwin.stumbleupon.com/ _______________________________________________ ILUGC Mailing List: http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
