mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-25 22:38:04 +02:00
Haskell-Beispiele hinzugefügt
This commit is contained in:
parent
137a44cd5e
commit
8e73ed0910
6 changed files with 69 additions and 2 deletions
|
@ -0,0 +1,12 @@
|
|||
import Data.List --sort und reverse
|
||||
|
||||
hIndex :: (Num a, Ord a) => [a] -> a
|
||||
hIndex l = helper (reverse (sort l)) 0
|
||||
where helper [] acc = acc
|
||||
helper (z:ls) acc
|
||||
| z > acc = helper ls (acc + 1)
|
||||
| otherwise = acc
|
||||
|
||||
-- Alternativ
|
||||
hindex1 = length . takeWhile id . zipWith (<=) [1..] . reverse . sort
|
||||
hindex2 = length . takeWhile (\(i, n) -> n >= i) . zip [1..] . reverse . sort
|
Loading…
Add table
Add a link
Reference in a new issue