purescript-control
purescript-control copied to clipboard
fix function -> add example
I'm not entirely sure about this example: does it help to write the fibonacci function in this way? as opposed to the more direct version:
fib n
| n <= 0 = 1
| n == 1 = 1
| otherwise = fib (n - 1) + fib (n - 2)
I think I'd rather use an example where fix is needed to prevent an infinite loop, like for example if you were writing a JSON parser where the parser for any JSON value needs to depend on the parser for arrays, but the parser for arrays also needs to depend on the parser for any JSON value.
agree, my example was just to help me to understand lazy class for functions
I think I'd rather use an example where fix is needed to prevent an infinite loop
yes, this example would be much better, but I dont know how to write it