
hi all i'm going to write an exam in haskell tomorrow (monday) and i therefore i have to understand what this does: repeat_until::(a->Bool)->(a->a)->a->a repeat_until crit change x |crit x = x --zufrieden |otherwise = repeat_until crit change (change x) --weiter fix::(Float->Float)->Float->Float fix f = repeat_until pred f where pred x = (abs(f x -x) <= 0.01) square::Float->Float square x = x*x this is the use: ================ Prelude> :l e:\haskell\burstall.hs Main> fix square 0.01 0.01 (56 reductions, 80 cells) Main> fix square 0.1 0.01 (92 reductions, 128 cells) Main> fix square 1 1.0 (54 reductions, 77 cells) Main> Main> it seems that i dont have a clue how it works. maybe some of you could explain it to me that i can pass the exam tomorrow, thanx and best regards, armin. -- armin langhofer snail: fischer von erlachstr. 29 snail: a-5020 salzburg phone: +43 699 11648495 email: office@langhofer.at gnupg: http://langhofer.at/pubkey.txt

On 2004 December 19 Sunday 17:31, armin langhofer wrote:
this is the use: ================ Prelude> :l e:\haskell\burstall.hs Main> fix square 0.01 0.01
it seems that i dont have a clue how it works. maybe some of you could explain it to me that i can pass the exam tomorrow,
Do you know what "fix square" would do with other argument values? If not, it would be worth your while to look at a whole lot more arguments because the results could be illuminating. Also, try replacing "square" with some other functions like "id" or (\x -> x - 1) respectively. Consider the value of the expression abs(f x -x) <= 0.01 if the function parameter "f" is "square". What values of x would produce a True or a False result? You'll find a close relationship between this question and the result of evaluating "fix square ...".
participants (2)
-
armin langhofer
-
Scott Turner