<div dir="ltr">I recently implemented the second as "join" - ala string, but for arbitrary separators and list elements.<div><br></div><div>I think the name "intersperse" is descriptive enough.</div><div><br></div><div>"intercalculate" no so much. I'd go with "join".</div><div><br></div><div>In the interest of consistency with other lists functions, I'd put the list argument last in each case.<br><br><div class="gmail_quote"><div dir="ltr">On Wed, Mar 2, 2016 at 8:54 AM Pierre Fenoll <<a href="mailto:pierrefenoll@gmail.com">pierrefenoll@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I find myself reimplementing the first one a lot, for use with iolists.<br>
The second one is string:join/2, right?<br>
<br>
<br>
> On 02 Mar 2016, at 06:47, Jesper Louis Andersen <<a href="mailto:jesper.louis.andersen@gmail.com" target="_blank">jesper.louis.andersen@gmail.com</a>> wrote:<br>
><br>
> Hi Erlangers,<br>
><br>
> I'd really like to add two functions to the lists module from Haskell:<br>
><br>
> intersperse(List, Seperator) produces a list where each element is separated by separator, i.e.<br>
><br>
> X = [1,2,3]<br>
> [1, x, 2, x, 3] = lists:intersperse(X, x),<br>
><br>
> and it's cousin, intercalate(ListOfLists, Separator) is append(intersperse(ListOfLists, Seperator)), i.e,<br>
><br>
> Y = ["a", "b", "c"]<br>
> "a, b, c" = lists:intercalate(Y, ", "),<br>
><br>
> The implementations are straightforward and easy to write tests for, even property based tests if needed.<br>
><br>
> The rationale for this proposal is that I find myself implementing this function again and again in every project I write, and it is highly generic. It belongs in a typical list module. OCaml libraries add it. Haskell's Data.List has it. I believe Erlang, being a practical language, should have it as well.<br>
><br>
> Thoughts?<br>
><br>
> --<br>
> J.<br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div></div></div>