Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132944 views
License: OTHER
1
import Data.List --sort und reverse
2
3
hIndex :: (Num a, Ord a) => [a] -> a
4
hIndex l = helper (reverse (sort l)) 0
5
where helper [] acc = acc
6
helper (z:ls) acc
7
| z > acc = helper ls (acc + 1)
8
| otherwise = acc
9
10
-- Alternativ
11
hindex1 = length . takeWhile id .
12
zipWith (<=) [1..] . reverse . sort
13
hindex2 = length . takeWhile (\(i, n) -> n >= i) .
14
zip [1..] . reverse . sort
15