online advertising

Tuesday, June 2, 2015

Haskell 99 Problem 10


Please find the problem here.


Please see the solution as follow:

This is a relatively simple solution based on problem 9. As I really hated error, I have to wonder, is it possible to specialize list so that it is impossible to have empty list?

Creating a new data type called NonEmptyList is pretty trivial

data NonEmptyList a = Single a | Cons a (NonEmptyList a)

That's it. We could have use that instead.

No comments :

Post a Comment