Skip to content

Instantly share code, notes, and snippets.

@CarstenKoenig
Created July 31, 2014 07:32
Show Gist options
  • Save CarstenKoenig/8ef7731a1021efb2ee1c to your computer and use it in GitHub Desktop.
Save CarstenKoenig/8ef7731a1021efb2ee1c to your computer and use it in GitHub Desktop.
list rank
import Data.Maybe (fromJust)
import Data.List (sort)
rankList :: [Int] -> [Int]
rankList ns = map (fromJust . (flip lookup) ranks) ns
where ranks = zipWith (flip (,)) [1..] . sort $ ns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment