Software! Math! Data! The blog of R. Sean Bowman
The blog of R. Sean Bowman

Posts with tag “Haskell”

March 27 2016

A few days ago I was motivated to write a program in Haskell to test whether three numbers form a Pythagorean triple. There is an obvious solution, of course, but it’s always nice to shove monads in to problems that don’t need them. In this case, though, I found that the resulting solution did more than I had originally planned: if you pass the pTriples function a list of numbers, it will return a list of each Pythagorean triple that can be made from numbers in the list (without replacement). Cool!