とあるプログラマの変遷

level1

ループ最高!ループほど明確なものはないだろう。

int fact(int n){
  int result = 1;
  for(int i = 1 ; i <= n ; i++){
    result *= i;
  }
  return result;
}

level2

再帰関数最高!!ループなんて必要ないだろう。

fact 0 = 1
fact n = n * fact (n-1)

level3

foldl最高!!!
いちいち再帰関数を書くのは面倒。mapとfoldlを組み合わせて書くべきだ。

fact n = foldl (*) 1 [1..n]
-- あるいはfact n = product [1..n]