Should it? I tried to explain it, but if you are not convinced just give it a try.<br><br><br>
><br>
> Guess what? You do not need the special case for [], because "all _ [] =<br>
> True" allways. So if the list is empty, it won't even try evaluating<br>
> "first".<br>
><br><br><div class="gmail_quote">On 12 March 2010 14:25, Salil Wadnerkar <span dir="ltr"><<a href="mailto:rohshall@gmail.com">rohshall@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Fri, Mar 12, 2010 at 10:21 PM, Ozgur Akgun <<a href="mailto:ozgurakgun@gmail.com">ozgurakgun@gmail.com</a>> wrote:<br>
> Another boring variant from me then.<br>
><br>
> isHomogeneous xs = all (first==) xs<br>
> where first = head xs<br>
<br>
<br>
</div>Shouldn't<br>
head xs<br>
give an exception on an empty list?<br>
<div><div></div><div class="h5"><br>
<br>
<br>
><br>
> Guess what? You do not need the special case for [], because "all _ [] =<br>
> True" allways. So if the list is empty, it won't even try evaluating<br>
> "first".<br>
><br>
> Cheers,<br>
><br>
> On 12 March 2010 14:08, Daniel Fischer <<a href="mailto:daniel.is.fischer@web.de">daniel.is.fischer@web.de</a>> wrote:<br>
>><br>
>> Am Freitag 12 März 2010 14:41:11 schrieb Daniel Fischer:<br>
>> ><br>
>> > isHomogeneous :: Eq a => [a] -> Bool<br>
>> > isHomogeneous [] = True<br>
>> > isHomogeneous (x:xs) = all (== x) xs<br>
>> ><br>
>><br>
>> Variant, getting rid of the special case for an empty list:<br>
>><br>
>> isHomogeneous :: Eq a => [a] -> Bool<br>
>> isHomogeneous xs = and (zipWith (==) xs (drop 1 xs))<br>
>> _______________________________________________<br>
>> Beginners mailing list<br>
>> <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
>> <a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
><br>
><br>
><br>
> --<br>
> Ozgur Akgun<br>
><br>
> _______________________________________________<br>
> Beginners mailing list<br>
> <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
><br>
><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Ozgur Akgun<br>