On Wed, 2002-09-18 at 01:26, Hamilton Richards wrote: > You can get the effect you're after by using let-expressions: > > > functn :: Int -> Int > > functn i > > | i>5 = let t = functn (i-2) in t * i > > | i>0 = let t = functn (i-1) in t * i > > | otherwise = 1 > > 'where' is part of the syntax of definitions, not expressions. This > enables a name defined in a where-clause to be used in more than one > guarded expression.
Thanks for this! It would seem "let ... in ..." is what I want. But I'm a bit confused about how to use the off-side rule in conjunction with let. Do I do: let a=1 b=2 c=3 in a*b*c or do I do: let a=1 b=2 c=3 in a*b*c or, in the context of a guard, do I do: | i>5 = let a=1; b=2; c=3 in a*b*c Basically I'm a bit confused about how the offside rule works in various situations. With "if ... then ... else ..." I don't know whether I should be doing f x = if x>5 then x*x else 2*x or f x = if x>5 then x*x else 2*x or f x = if x>5 then x*x else 2*x or what! Hugs seems to think they are all legal. Is there any rational as to how to do layout? Any tips would be greatly appreciated! Thanks, Mark. _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell