Thanks! BTW, as you suggested I tried modifying the code to use lazy gather. That actually doubled the execution time, and I think the reason is that when grepping through one million elements the list _still_ has to be generated.

I learned something new from trying, though. When running an operation on a lazy list — the operation being grep in my case — the resulting list is lazy as well. Method like .elems won’t work on lazy lists, so I had to explicitly convert the returned lazy list to a regular list by using the eager keyword, as in…

my @new-list = eager @lazy-list;

There’s apparently always something new to learn.

    Jo Christian Oterhals

    Written by

    Norwegian with many interests. Programming being one of them.

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade