On Thu, 18 Nov 1999, Wayne Young wrote:
> I'm still getting the syntax correct (playing with simple functions,
> etc) and was wondering how I would define Ackermann's function in
> Haskell.
See http://www.engr.mun.ca/~theo/Publications/indExamp.lgs
for three versions. The simplest is just
> p 0 n = n+1
> p (m+1) 0 = p m 1
> p (m+1) (n+1) = p m (p (m+1) n)
The other two illustrate how to do it using combinators rather than
explicit recursion.
> I'm curious to see how Haskell (using Hugs) will outperform C
> and Pascal for this beast.
If you are comparing speed, I doubt Hugs will outperform a compiled C or
Pascal program, as Hugs is an interpreter. It might be interesting to
compare compiled Haskell to C or Pascal.
Cheers,
Theo Norvell
----------------------------
Dr. Theodore Norvell [EMAIL PROTECTED]
Electrical and Computer Engineering http://www.engr.mun.ca/~theo
Engineering and Applied Science Phone: (709) 737-8962
Memorial University of Newfoundland Fax: (709) 737-4042
St. John's, NF, Canada, A1B 3X5