It really depends on the list. For a normal, lazily priced Int list on my computer, I see that this function works after about 2 seconds for 10 ^ 9 items, 0.2 seconds for 10 ^ 8 and 0.3 seconds for 10 ^ 7, so it seems to be runs in linear time. You can verify this yourself by passing the +RTS -s -RTS to your executable file when launched from the command line.
I also tried to run it with a lot of cores, but it does not seem to do anything, but slightly increases memory usage.
The added bonus of lazy computing is that you only make one pass through the list. filter and length turn into a single cycle by the compiler (with optimization turned on), so you save memory and efficiency.
bheklilr
source share