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

would you be interested in adding an intersperse function? #132

Open
danse opened this issue Oct 25, 2017 · 4 comments
Open

would you be interested in adding an intersperse function? #132

danse opened this issue Oct 25, 2017 · 4 comments
Labels
type: enhancement A new feature or addition.

Comments

@danse
Copy link

danse commented Oct 25, 2017

if you think it's a good idea, i will try to put together a pull request

@paf31
Copy link
Contributor

paf31 commented Oct 25, 2017

We have intercalate in monoids, but this seems like it'd be worth having here.

@danse
Copy link
Author

danse commented Oct 25, 2017

so ... can the same effect be achieved by using intercalate? and if so, do you picture the body of intersperse here to rely on intercalate and the monoidal instance?

@paf31
Copy link
Contributor

paf31 commented Oct 25, 2017

You could always do something like intercalate [x] (map singleton xs) but that's hardly ideal. If we did add it here, it should probably be monomorphic and tail recursive.

@danse
Copy link
Author

danse commented Oct 26, 2017

i realise that this could be a long shot for me giving my current availability and knowledge of Purescript. i built my naive implementation that fixes my probem (i was actually working with Arrays), but contributing it to the library requires a familiarity with the type classes that i still don't have.

it could still be worth to use this issue to collect related information. i see that there is a similar issue on arrays, and as far as i understand the recommended solution there is to use a monoid or foldable instance. it's difficult for me at the moment to reason about the efficiency and to figure out whether the same approach should be used for both arrays or lists or whether lists would work better with a dedicated implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A new feature or addition.
Projects
None yet
Development

No branches or pull requests

3 participants