[Haskell-cafe] [Q] What calls what

Andre Betz mail at andrebetz.de
Thu Feb 19 16:43:36 EST 2004


Hi,

I have a question about the following function. 

I don't know how the definition after "where" are called.

For example, in ( D x2 (-y1) , b ++ b2 ) there is x2 defined in the
where-block. So does that mean that it calls the iteratin at line 7? But what is with
b2, does it also calls the line 7?

Who calls the definition in line 3 and who calls the def in line 7?

Many thanks 
Andre

1 test :: ( D , [Int] ) -> ( D , [S] ) -> ( D , [Int] )
2 test ( D x y , b ) ( D dx dy , st ) = ( D x2 (-y1) , b ++ b2 )
3    where ( x1 , y1 ) = head $ dropWhile ( ( > 0 ) . snd ) $ iterate inc (
x , y )
4
5	  inc ( n , m ) = ( n+1 , m+1 ) 
6
7	  ( b2 , x2 ) = head $ do
8			S ( D x3 sty ) pl _ sb <- st
9			guard $ sty == -y1
10			return ( [1,2,3] ++ sb , x3 + sb)

-- 
**********************************************************
**
*           André Betz              *                      *
*           ----------              *                      *
*    EMail: mail at andrebetz.de       *    WW                *
*      Web: http://www.andrebetz.de *   /__\               *
*      ICQ: 117759780               *  | oo |   _WWWWW_    *
*    Mobil: +49 (0)162 8847 391     * (|_()_|) /  o o  \   *
*   Office: +49 (0)9131 82611 27    *   \__/ (|  __O__  |) *
*     Home: +49 (0)911 6695 558     *  /|\/|\  \ \___/ /   *
* Tel./Fax: +49 (0)89  1488 224189  * |||||||| /-------\   *
*    Snail: Hirschelgasse 34        * |||||||||=========|  *
*           D-90475 Nürnberg        * |||||||||=========|  *
**********************************************************
**



More information about the Haskell-Cafe mailing list