The Easiest Way to Save and Share Code Snippets on the web

washing haskell for steffen

haskell

posted: Dec, 13th 2011 | jump to bottom

  1. import Test.QuickCheck
  2. import Data.List
  3.  
  4. -- Contract
  5. sortWashing :: Eq a => [a] -> [[a]]
  6.  
  7. -- Purpose
  8. -- Takes a list of clothes and sorts them into groups which can be washed together.
  9. -- This might help Steffen to find out what can be washed together.
  10.  
  11. -- Examples
  12. -- sortWashing ["Boxershort", "T-Shirt", "T-Shirt"] : [["T-Shirt", "T-Shirt"], ["Boxershort"]]
  13.  
  14. -- Definition
  15. sortWashing xs = group xs
  16.  
  17. -- Test
  18. prop_purity xs = and [ True | f:s:ys <- sortWashing xs, f == s]
  19. where types = (xs :: [Char])
62 views