Racket:
> (define (fact n)
(if (= n 1)
1
(* n (fact (- n 1)))))
> (fact 6)
720
OCaml: # let rec fact = function
| 1 -> 1
| n when n > 1 -> n * (fact (n - 1))
in fact 6;;
- : int = 720 fac n = product [1 .. n]https://people.willamette.edu/~fruehr/haskell/evolution.html
fac 1 = 1
fac n = n * (fac (n - 1))
which is a working Haskell implementation?I mean, in Scheme it is longer to write. I enjoy Lisps and use Emacs for everything, but Haskell can be as terse, or even more terse. (Which is not always a good thing.)
What do you mean? It's one of the first things taught in any tutorial for the ML family or Haskell.