1 Mar
2001
1 Mar
'01
9:13 a.m.
runRandom last max num | num > 1 = runRandom (fst new) max (num-1) | otherwise = snd new
What's the difference between the pipe-syntax, and a case statement, i.e. writing the function as
runRandom last max num = case num of 1 -> runRandom .... otherwise -> snd new
Eeek! This is not the same function! (num>1) =/= (num==1) Oh, and it isn't type-correct either. Try: runRandom last max num = case num>1 of True -> runRandom .... otherwise -> snd new Oops. No. Try again: runRandom last max num = case num>1 of True -> runRandom .... False -> snd new That's better. These transformations by hand can be tricky, huh? Regards, Malcolm