Idris2/tests/idris2/perf008/FinPerf.idr
2021-06-14 17:28:58 +01:00

20 lines
406 B
Idris

import Data.Fin
import Data.Vect
tail : (Fin (S n) -> a) -> (Fin n -> a)
tail f = f . FS
toVectFun : {n : Nat} -> (Fin n -> a) -> Vect n a
toVectFun {n = Z} _ = Nil
toVectFun {n = S m} f = (f FZ) :: (toVectFun (tail f))
N : Nat
N = 500
xs : Vect (S N) Nat
xs = toVectFun {n = S N} finToNat
main : IO ()
main = putStrLn $
"xs(" ++ show N ++ ") = " ++ show (index (fromInteger (natToInteger N)) xs)