Skip to content

Instantly share code, notes, and snippets.

@klapaucius
Last active January 3, 2016 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klapaucius/8536959 to your computer and use it in GitHub Desktop.
Save klapaucius/8536959 to your computer and use it in GitHub Desktop.
> import GHC.HeapView
>
let evLength n l = do
ht <- buildHeapTree n (asBox $ l)
let cnt (HeapTree _ (ConsClosure {ptrArgs = [hd,tl]})) = 1 + cnt tl
cnt _ = 0
return $ cnt ht
> let l = [1..]
> l !! 10
11
> evLength 10000 l
11
> l !! 100
101
> evLength 10000 l
101
> l !! 1000
1001
> evLength 10000 l
1001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment