# fixed point

Harris, Andrew Andrew.Harris at jhuapl.edu
Sun Oct 26 19:24:26 EST 2003

```Hi -

I am trying to do Exercise 9.9 in HSOE; and I've come up with an
answer that works but I'm not sure if it answers the question properly.  The
problem is:

The Question:
-------------

Suppose we define a function "fix" as:

fix f = f (fix f)

Suppose further we have a recursive function:

remainder :: Integer -> Integer -> Integer
remainder a b = if a < b then a
else remainder (a - b) b

Rewrite this function using "fix" so that it's not recursive.

----------

wierdFunc x y z = if y - z > z then ((\a b c -> a b c) x (y-z) z)
else ((\a b c -> a b c) (\d e -> d) (y-z) z)

myRemainder = fix wierdFunc

My Question:
------------

Does the ((\a b c -> a b c) x (y-z) z) mean that I've not removed the
recursion?  I was assuming that I was returning a function that is to be
evaluated and not actually doing any recursion.  That's why I thought I
answered the question.  However, I have a headache now and would like
another opinion.

thanks,
-andrew
```