Closed floer32 closed 2 years ago
This is definitely something we want to add!
Following the existing naming convention (e.g. round
) I think it makes most sense to use join
for this function, although I share your concern about it potentially being confusing.
We've briefly discussed that having namespaces would be useful (something like string::join(…)
), and maybe time has come to introduce it.
However, considering how common this function is I think it's fine to introduce it as join(…)
now and then later make it fit into a namespace.
Thoughts @atombender and @j33ty?
I'm fine with join()
until the day we will consider adding "modules" to collect functions.
Hi! We have now launched this functionality as array::join()
, along with a bunch more stuff.
We have also launched a new GROQ spec, which you can read about in our blog: Content is Queryable: (Re)Introducing GROQ.
I think it seems reasonable to consider this because groq already has ways of restructuring (and reformatting) data; i.e. projections, functions, coalescing, and certain kinds of concatenation.
It's pretty common to want to stringify an array with a separator in between (like
,
). In Python, that's[...].join(", ")
. In JS, it'sArray.join([...], ", ")
. (Putting those partly for sake of searches if someone looks for those and groq, that's what I searched for initially.) There'sCONCAT_WS
in SQL.I figure this is a Function. I think it'd be consistent with the existing syntax to implement it like
join(<array>, ", ")
-- but to avoid confusion with databaseJOIN
s, maybe it would be better to name itstrjoin(<array>, ", ")
.Thoughts?