Programming with Passion

Design, the Coding and Everything

Menu

Skip to content
  • Home
  • About

Small Haskell idiom in PHP

Posted on August 9, 2010 by Mohammed Irfan

I’ve been watching Erik Meijer’s lectures on Functional Programming Fundamentals on Channel 9. In lecture 2 he shows this Haskell code:

factorial n = product [1..n]

Can this be translated into PHP? Well, not so elegant as Haskell’s, I came up with the following code:

$n = 5;
$factorial = array_product(range(1, $n)); // for PHP5 only!

Interesting, isn’t it?

/ Tagged haskell, php / Leave a comment

Archives

  • August 2010

Meta

  • Register
  • Log in
Blog at WordPress.com. / Theme: Truly Minimal by FlareThemes.
Follow

Get every new post delivered to your Inbox.

Powered by WordPress.com