added python and haskell implementations