
12 Mar
2010
12 Mar
'10
2:40 p.m.
On Fri, Mar 12, 2010 at 03:31:54PM +0100, Daniel Fischer wrote:
Am Freitag 12 März 2010 15:25:48 schrieb Salil Wadnerkar:
On Fri, Mar 12, 2010 at 10:21 PM, Ozgur Akgun
wrote: Another boring variant from me then.
isHomogeneous xs = all (first==) xs where first = head xs
Shouldn't head xs give an exception on an empty list?
Only if it's demanded, which it isn't here, since all doesn't look at the condition when facing an empty list.
But it's good practice to never call head on a list which may be empty, so I wouldn't like Ozgur's variant in real code. It's great for golf, though :D
I would argue that it's good practice simply to never call head at all. I stopped a while ago, and I haven't missed it. =) -Brent