[Haskell-beginners] Function nesting

Daniel Fischer daniel.is.fischer at web.de
Thu Jan 21 09:55:39 EST 2010

Am Donnerstag 21 Januar 2010 15:02:11 schrieb Zbigniew Stanasiuk:
> Hi all,
> I've just started learning Haskell and I have no idea how to nest
> function in following structure:
> Mod(5*Mod(4*Mod(3*Mod(2*Mod(1, m), m), m), m), m) ... etc.
> Could someone help me.

Instead of func(a,b), write func a b. Arguments which are compund 
expressions themselves must be parenthesized, so

mod (5*mod (4*mod (3*mod (2*mod 1 m) m) m) m) m

But that is completely unreadable.

foldl' (\z x -> (x*z) `mod` m) 1 [1 .. 5]

Much better :)
> Regards,
> Zbig

More information about the Beginners mailing list