Pattern guards
Iavor Diatchki
iavor.diatchki at gmail.com
Thu Sep 28 18:11:54 EDT 2006
Hello,
This particular example we can do with pattern guards
(although it seems that a simple 'case' is more appropriate for this example)
On 9/28/06, Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
> Hello Conor,
>
> Thursday, September 28, 2006, 10:30:46 PM, you wrote:
>
> > gcd x y | compare x y ->
> > LT = gcd x (y - x)
> > GT = gcd (x - y) y
> > gcd x _ = x
mygcd x y
| LT <- z = mygcd x (y-x)
| GT <- z = mygcd (x-y) y
where
z = compare x y
mygcd x _ = x
-Iavor
More information about the Haskell-prime
mailing list