callumeidson

Haskell Wizardry

Nov 8th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. comp :: (Float, Float) -> Float -> Int
  2. comp (l, u) h
  3.    | h > l && h < u = 1
  4.    | otherwise      = 0
  5.  
  6. counter :: [Float] -> [Float] -> [Int]
  7. counter hbs hs = (\m -> [sum( map f l) | (f, l) <- m]) zipfuncs
  8.  where
  9.    funcs = compfuncs hbs
  10.    n = length funcs
  11.    repheights = take n (repeat hs)
  12.    zipfuncs = zip funcs repheights
  13.    
  14. compfuncs :: [Float] -> [Float -> Int]
  15. compfuncs hbs = map comp (zhb hbs)
  16.  
  17. --hb :: [Float]
  18. --hb      = [143.74, 145, 155, 160.51]
  19.  
  20. zhb :: [Float] -> [(Float, Float)]
  21. zhb hb = zip (init hb) (tail hb)
Advertisement
Add Comment
Please, Sign In to add comment