ec1e695d5f013a13fd9c69e02267209d4b501f2766b52d6c944e1c2245ca4f59

Download raw

Created: 2023-12-19 03:40:10.302489 UTC

Size: 495

Preview (limited to 512 bytes)

"module Algo.ListRank\nwhere\n\nimport Data.Vector.Unboxed as V\n\nlistRank :: Int -> Vector Int\n{-# NOINLINE listRank #-}\nlistRank n = pointer_jump xs val\n where\n xs = 0 `V.cons` V.enumFromTo 0 (n-2)\n\n val = V.zipWith (\\i j -> if i == j then 0 else 1)\n xs (V.enumFromTo 0 (n-1))\n\n pointer_jump pt val\n | npt == pt = val\n | otherwise = pointer_jump npt nval\n where\n npt = V.backpermute pt pt\n nval = V.zipWith (+) val (V.backpermute val pt)\n\n"


A service provided by FP Complete