Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. importing lib in haskell after installing with cabal
  2. -----------------------------------------------------------------------------
  3. --
  4. -- Module      :  Main
  5. -- Copyright   :
  6. -- License     :  AllRightsReserved
  7. --
  8. -- Maintainer  :
  9. -- Stability   :
  10. -- Portability :
  11. --
  12. -- |
  13. --
  14. -----------------------------------------------------------------------------
  15.  
  16. module Main (
  17.     main
  18. ) where
  19.  
  20. import Data.List ((\))
  21. import GHC.Arr (accumArray, elems, Array(..))
  22.  
  23.  
  24.  
  25. minfree :: [Nat] -> Nat
  26. minfree xs = head([0 ..])\ xs
  27.  
  28. search :: Array Int Bool -> Int
  29. search = length takeWhile id . elems
  30.  
  31. checklist :: [Int] -> Array Int Bool
  32. checklist xs = accumArray(V) False (0,n)
  33.                (zip (filter (<= n) xs) (repeat True))
  34.                where n = length xs
  35.  
  36. main = (
  37.  
  38.     minfree[0, 2, 5]
  39.     )
  40.        
  41. import Data.Number.Nat