Open ChristianGruen opened 9 months ago
renaming fn:intersperse to fn:join;
Could also call it sequence-join
or items-join
, then it is more consistent with string-join
items-join
variant would also be consistent with items-after
adding a parameter to array:join: $separator as array() := (); and
or it could be a sequence.
array:join([1,2,3], '-')
to make it [1,'-',2,'-',3]
Could also call it
sequence-join
oritems-join
, then it is more consistent withstring-join
I suggested fn:join
as we already have array:join
and various other sequence functions that don’t include sequence
.
items-join
variant would also be consistent withitems-after
The items-
functions will probably be renamed:
https://qt4cg.org/pr/855/xpath-functions-40/Overview.html#func-subsequence-after https://github.com/qt4cg/qtspecs/issues/844#issuecomment-1826276165
or it could be a sequence.
array:join([1,2,3], '-')
to make it[1,'-',2,'-',3]
I thought about this, but then it wouldn’t be possible to include multiple arrays.
+1 to fn:join
(and array:join
)
I'm still a little uneasy that for many people with a database background, join means relational equijoin.
I noticed that during XML Prague the PRG-required
label was added to this issue.
Does someone remember which of my suggestions were regarded as necessary? Would it be helpful if I create a PR for my initial proposal?
Does someone remember
Not I, I'm afraid.
With
string-join
, you can create a string for multiple strings, optionally interspersed with a separator.array:join
can be used to create an array from multiple arrays.fn:intersperse
, which has been added to the XQuery 4 draft, does something very similar, and early feedback indicates that the function is useful, but easily to overlook due to its name.I propose to unify the functions by…
fn:intersperse
tofn:join
;array:join
:$separator as array(*)* := ()
; andfn:string-join
:$separator as xs:string* := ()
.Examples
string-join(('1','2','3'), '-')
'1-2-3'
array:join([[1],[2],[3]], ['-'])
[1,'-',2,'-',3]
join((1,2,3), '-')
(1,'-',2,'-',3)
intersperse((1,2,3),'-')
string-join(('1','2','3'))
'123'
array:join([[1],[2],[3]])
[1,2,3]
join((1,2,3))
(1,2,3)
intersperse((1,2,3))
(or just
(1,2,3)
)string-join(('1','2','3'), ('-','+')
'1-+2-+3'
array:join([[1],[2],[3]], ['-','+'])
[1,'-','+',2,'-','+',3]
join((1,2,3), ('-','+'))
(1,'-','+',2,'-','+',3)
intersperse((1,2,3),('-','+'))