[Haskell-cafe] Implementing parental using blood type

Rafael Almeida almeidaraf at gmail.com
Sun Jun 29 07:15:02 UTC 2014


Good idea. Attached is the best solution I could think of. I think it reads
quite elegantly :)


On Sun, Jun 29, 2014 at 2:05 AM, Francesco Ariis <fa-ml at ariis.it> wrote:

> On Sat, Jun 28, 2014 at 11:16:31PM -0300, Rafael Almeida wrote:
> > I'm trying to practice my Haskell. So I had the idea of making a program
> > which, given a mother's and a child blood type, it can determine whether
> a
> > certain father is possible or not.
> >
> > Please take a look on this gist with my implementation:
> >
> >
> https://gist.github.com/aflag/14429dfb2e89791a44e2#file-parentaltesting
> >
> > Would you care to comment on it? It looks a bit cumbersome to my eyes.
> I'm
> > trying to find the most intuitive and elegant way of do it. I'm not so
> much
> > worried with performance.
>
> Since your 'main' function returns a Bool (possible/impossible), a simpler
> way to approach the problem is to calculate the potential blood-type of
> child
> C given parents A and B and then check the actual blood-type passed against
> this list (I attach a .hs with such solution).
>
> The 'cumbersome' part is the |Genes -> BloodType| conversion (and
> vice-versa);
> you can calculate the inverse instead of typing it out, but it will still
> be
> cumbersome.
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140629/0d6e8272/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: blood.hs
Type: application/octet-stream
Size: 1256 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140629/0d6e8272/attachment.obj>


More information about the Haskell-Cafe mailing list