Hello:

Suppose I have a function 'g' which either iteratively or recursively sums
up results of calls to 'f'.  I've predetermined that there will only ever
be 20 things to sum up.

I think the easiest solution would be iteration.  However, I'm new to
Haskell and it doesn't seem to have looping constructs?

Therefore, perhaps the recursive approach would work.  But unfortunately,
I want to call my 'g' function without a parameter and get a result back
-- but yet I'll need to pass a parameter to it in order for it to recurse.
Catch 22.

Any ideas?  I thought something like this might work:

f :: Integer -> Integer
f x
  /* return a predetermined value depending on what 'x' contains */

g :: Integer -> Integer -> Integer
g x y = if x == 0 then 0 else g f x y

However, I'd have to call this like, 'g 20 0' which is not what I had in
mind.

Any suggestions?  Thanks in advance.

--------------< LINUX: The choice of a GNU generation. >--------------
Steve Frampton  <[EMAIL PROTECTED]>  http://qlink.queensu.ca/~3srf

Reply via email to