Skip to content

Mysterious run time difference between two different expressions for the same function #49

@Glidos

Description

@Glidos

I have the contents of a file and wish to apply one regex to the first line and another regex to each of the other lines. This runs fast:

case lines contents of
    [] -> []
    h:b -> (:) <$> match hregex h <*> traverse (match bregex) b

This runs slow:

zipWithM match (hregex : repeat bregex) $ lines contents

That's sort of a shame. Just as I'm writing this, I'm realising that the first is probably faster because reductions can be applied to match bregex just once. Still, I'd be interested to hear your thoughts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions