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 joinMap #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add joinMap #40

wants to merge 1 commit into from

Conversation

ursi
Copy link

@ursi ursi commented Mar 24, 2020

I was using List.map with String.join until I realized that that goes through the whole list twice. I tried List.foldl but then I realized that couldn't get me the same behaviour as String.join, where the separator is only inserted in between strings.

@ursi
Copy link
Author

ursi commented Mar 25, 2020

Thinking about it more, I guess you can just fold if you check to see if the accumulation is the empty string and handle it differently (I might change the implementation to that since it seems like it would be faster). That being said, having experienced using joinMap in my own code, I still would prefer it be its own function.

@ursi
Copy link
Author

ursi commented Mar 28, 2020

Apparently recursion is faster https://ellie-app.com/8rJw9pbcTpBa1

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.

1 participant