<div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">I've been reviewing the library, and have come unstuck with the <b>id</b> function.<br>
What's its purpose and can someone give me an example of its practical use.<br></blockquote></div><br>It's purpose is simply to be the identity function. The type says exactly what it does.<br><br>Prelude> :t id<br>
id :: a -> a<br><br>It's often useful in combination with higher-order functions.<br><br>Prelude> :t foldr (.) id<br>foldr (.) id :: [a -> a] -> a -> a<br><br>Here's a slightly complicated way to add a list of numbers:<br>
<br>Prelude> foldr (.) id (map (+) [1..5]) 0<br>15<br><br>Sean<br>