[erlang-questions] Proposal: add lists:intersperse/2 and lists:intercalate/2

Joe Armstrong erlang@REDACTED
Tue Mar 8 17:56:13 CET 2016


I'd call it punctuate (to mark or divide  with punctuation marks) - since this
is what I'd use this of, so punctuate(Claues, ';') means a a ';'
between clauses.

We could make a new library called stacks which is all of lists renamed with new
things in and phase out lists.

Lists are actually stacks - explaining how to reverse a stack to beginners
is far easier than a list - I just get them to think of a stack of
plates in a restaurant,
one empty one full ....

Just because lisp go it wrong doesn't mean to say that everybody else
should follow


/Joe


On Mon, Mar 7, 2016 at 11:24 PM, Chandru
<chandrashekhar.mullaparthi@REDACTED> wrote:
> On 7 March 2016 at 16:04, Loïc Hoguin <essen@REDACTED> wrote:
>>
>> On 03/07/2016 04:53 PM, Garrett Smith wrote:
>>>
>>> On Mon, Mar 7, 2016 at 9:28 AM Jesper Louis Andersen
>>> <jesper.louis.andersen@REDACTED
>>> <mailto:jesper.louis.andersen@REDACTED>> wrote:
>>>
>>>
>>>     On Mon, Mar 7, 2016 at 4:08 PM, Garrett Smith <g@REDACTED
>>>     <mailto:g@REDACTED>> wrote:
>>>
>>>         It's vague, as is intercalculate, but as it's superficially
>>>         doing what string "join" does with chars has some precedence
>>>         within Erlang. I wouldn't call it hopeless.
>>>
>>>
>>>     I'm probably leaning away from using 'join' at this point, since
>>>     'join' already have type
>>>
>>>     join :: Monad M => m (m a) -> m a
>>>
>>>     so from an FP perspective, that name is highly confusing since it is
>>>     in use in monadic context and is used to join monadic data into its
>>>     own monadic context. For a list, join is essentially 'append':
>>>
>>>     Prelude Control.Monad> join ["a", "b", "c"]
>>>     "abc"
>>>
>>>     But join is monadic, so `join $ Just Nothing` evaluates to `Nothing`.
>>>
>>>
>>> Sigh. Okay, so the future naming discussions will involve with word
>>> monad and monadic?
>>>
>>> You've seen the discussions around adoption and the disruptive influence
>>> of Elixir?
>>>
>>> For whatever reason FP pedantry is not a draw for me. When I need
>>> inspiration I look to Python. Maybe that's the wrong direction and we
>>> need to drive our community through more gates.
>>
>>
>> I am completely with you on that. If the function was called
>> intercalculate I'd never find it and would continue writing my own.
>>
>
> I second this. I'm part of the vast number of unwashed masses who've never
> heard of the term intercalculate, and if I came across it in a developer's
> code would think that they were being a bit too clever. Like many others I
> have written this piece of code several times and invariably named it
> 'concat_with_separator' - a mouthful but it conveys (at least to me) what
> exactly the function is doing.
>
> cheers,
> Chandru
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list