[Haskell-cafe] How to variables

Bernard Pope bjpop at cs.mu.OZ.AU
Tue Jul 19 02:21:10 EDT 2005


On Tue, 2005-07-19 at 09:48 +0400, Bulat Ziganshin wrote:
> Hello robert,
> 
> Monday, July 18, 2005, 10:14:43 PM, you wrote:
> 
> 
> rd> main = loop 0 0 0 -- initial values
> rd>   where loop loop_num xpos ypos =
> rd>              do e <- pollEvent
> rd>                 let xpos' = <calculate new xpos>
> rd>                     ypos' = <calculate new ypos>
> rd>                 someActionInvolvingPosition xpos' ypos'
> rd>                 when breakCondition (return ())
> rd>                 loop (loop_num+1) xpos' ypos'
> 
> the last two lines should be
> 
> if breakCondition
>   then return ()
>   else loop (loop_num+1) xpos' ypos'

Or even better:

   unless breakCondition $ loop (loop_num+1) xpos' ypos'

Bernie.



More information about the Haskell-Cafe mailing list