[Haskell-cafe] Implementing parental using blood type

Alexander Solla alex.solla at gmail.com
Sun Jun 29 07:45:18 UTC 2014


One thing I would suggest, as far as "Haskell style", is to make even short
programs like these into libraries.  You don't need to write a main
function to test or even run such a simple program, and if you write it as
a library, you can re-use it.


On Sun, Jun 29, 2014 at 12:15 AM, Rafael Almeida <almeidaraf at gmail.com>
wrote:

> 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
>>
>>
>
> _______________________________________________
> 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/eefd4f01/attachment-0001.html>


More information about the Haskell-Cafe mailing list