tail-recursion

    48热度

    6回答

    我写了这段代码,我假设len是尾递归,但仍然会发生堆栈溢出。哪里不对? myLength :: [a] -> Integer myLength xs = len xs 0 where len [] l = l len (x:xs) l = len xs (l+1) main = print $ myLength [1..10000000]