“interleave” and “join” are friendly for non-native English programmers.
Otherwise +1
- Dmitry
Hi Joe,
I did it in crownedgrouse/geas_devel database either in term and yaml format starting R15.
And as Vlad said, my project geas does this work on project and dependancies, compiled or not. Integrated in rebar and erlang.mk.
Enjoy.
https://github.com/inaka/xref_runner
--
Loïc Hoguin
http://ninenines.eu
Author of The Erlanger Playbook,
A book about software development using Erlang
So to catch up:
* On Richard's comments of other uses than for a string:The obvious use in Erlang is to produce iolist() types for binary data: intersperse($, [<<"a">>, <<"b">>, <<"c">>]) is relatively common in my code. The slightly less obvious use is to interleave a simplifier step in between every optimization step of a compiler, but I've only done that once in my life and I'm not sure it is that useful :)
* On the name choice of 'intersperse/intercalate':I think the semantics I'm aiming for is so close to the OCaml(Core)/Haskell implementations I'm willing to reuse that name. Another valid name is 'join' which is common in many other languages. I don't think one is better than the other, but the FP roots in me says we should adopt FP-language naming.
The problem with 'join' as a name is that it is hopelessly vague.
Xs++Ys joins Xs and Ys. [{K,X,Y} || {K,X} <- Xs, {K,Y} <- Ys} also
joins Xs and Ys. Some versions of join will let me do
"a, b, and c" and some won't. And so it goes.
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.
On Mon, Mar 7, 2016 at 4:08 PM, Garrett Smith <g...@rre.tt> 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 typejoin :: 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`.
I mean, C++ also uses the word Functor, but they know jack shit about what that means mathematically. And almost every language knows jack shit about what join really is either :)
I am completely with you on that. If the function was called
intercalculate I'd never find it and would continue writing my own.
Precision is important, but it's even more important to think about who
the users are (or who you want them to be) and to lose some of this
precision to make things clearer for them. And as far as I can tell,
people don't go to Erlang because of their mathematical background.
Human languages are interesting like that, because the more you go for
precision the less people understand what you mean. Specialized terms
are only good for people with the same specialization. If you want the
most people to get it, use terms that a fourth grader would understand.
--
Loïc Hoguin
http://ninenines.eu
Author of The Erlanger Playbook,
A book about software development using Erlang
Sigh. Okay, so the future naming discussions will involve with word monad and monadic?
Besides, Haskell programmers are more likely to be able to adapt I think.
I think the original suggestion was not 'intercalculate', but 'intercalate', which may be accurate, but is very obscure, even
for native English speakers.
'Join' is both vague and specific, since it already has many specialized uses in algebra (e.g. lattices have 'meet' and 'join'), which Haskell has picked up.
I don't have a dog in this fight, but tentatively suggest 'delimit', which is ugly, but comprehensible based on the common usage of 'delimiter'.
Mike
... 'intercalculate' ... 'intercalate' ...
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
Please, if you are going to pour scorn on a word, at least COPY
the thing correctly. The proposal is not "intercalCULate" but
"intercalate",
and it's a real English word with a history going back at least 400 years
in English, 500 years in French, and 2500 years in Latin.
I think it's a bad name not because nobody knows what it means (I'd expect
any skilled native speaker of English to have met it several times) but
because
it means to insert ONE (unusual) thing into a sequence of (ordinary) things,
as in one leap day or one leap month into a year.
> 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.
Since 1997 (if not before) the SML Basis Library has included
fun concatWith _ [] = ""
| concatWith separator (string :: strings) =
concat (string :: map (fn x => separator^x) strings)
(*) I am using that as a specification. It would be a horrible
implementation.
Since 2015 that library includes
fun concatWithMap separator f data =
concatWith separator (map f data)
except that the point of concatWithMap is to fuse the calculations.
concat{,With}{,Map} are available on all vector-like types in the SML Basis.
Would those names do?
On 8/03/16 8:24 pm, Chandru wrote:
On 7 March 2016 at 16:04, Loïc Hoguin <es...@ninenines.eu <mailto:es...@ninenines.eu>> wrote:
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,
Please, if you are going to pour scorn on a word, at least COPY
the thing correctly. The proposal is not "intercalCULate" but "intercalate",
and it's a real English word with a history going back at least 400 years
in English, 500 years in French, and 2500 years in Latin.
I think it's a bad name not because nobody knows what it means (I'd expect
any skilled native speaker of English to have met it several times) but because
it means to insert ONE (unusual) thing into a sequence of (ordinary) things,
as in one leap day or one leap month into a year.
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.Since 1997 (if not before) the SML Basis Library has included
fun concatWith _ [] = ""
| concatWith separator (string :: strings) =
concat (string :: map (fn x => separator^x) strings)
(*) I am using that as a specification. It would be a horrible implementation.
the passionate pursuit of programming power from
precise analogies.