[Haskell-cafe] Implementing parental using blood type
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>
> 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:
>> > Would you care to comment on it? It looks a bit cumbersome to my eyes.
>> > trying to find the most intuitive and elegant way of do it. I'm not so
>> > 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
>> C given parents A and B and then check the actual blood-type passed
>> this list (I attach a .hs with such solution).
>> The 'cumbersome' part is the |Genes -> BloodType| conversion (and
>> you can calculate the inverse instead of typing it out, but it will still
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe