mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-24 20:23:11 +03:00
23 lines
508 B
Idris
23 lines
508 B
Idris
{-
|
|
|
|
Test that some library functions don't cause "Maximum call stack size exceeded"
|
|
errors.
|
|
|
|
So far, only Prelude.List.++ is tested.
|
|
|
|
-}
|
|
|
|
module Main
|
|
|
|
-- Until replicate is tail recursive, we roll our own for this test.
|
|
|
|
replicateOnto : List a -> Nat -> a -> List a
|
|
replicateOnto acc Z x = acc
|
|
replicateOnto acc (S n) x = replicateOnto (x :: acc) n x
|
|
|
|
tailRecReplicate : Nat -> a -> List a
|
|
tailRecReplicate = replicateOnto []
|
|
|
|
main : IO ()
|
|
main = putStrLn $ show $ length $ tailRecReplicate 50000 () ++ [()]
|