Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ungreedy alternative to replace #45

Closed
wants to merge 1 commit into from

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Dec 15, 2021

Closes: #44

While at it, also add doctests.

, testGroup "replaceAll"
[ u "t1"
(replaceAll ("x" <$ "a" <|> "y" <$ "ab") "tabc")
"txbc"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is indeed a behavioural difference. This one is ungreedy also in alternative, which is probably not what we want either. Maybe the issue is actually that findLongestInfix does not respect few.

@UnkindPartition
Copy link
Owner

Thanks Jan. I already merged your doctest commit.

As for the replace function, someone will have to dig into it and figure out what exactly is going on there and whether it needs fixing. Unfortunately, I don't know if I'll have for this in the nearest future. But if this fix works for you, you can just include this modified function in your own project.

@jtojnar jtojnar closed this Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

replace seems to be greedy even with few
2 participants