I want to concatenate two tuples in the way similar to concatenating vectors. For example, I have two tuples: a=(1,2,3)
and b=(4,5,6)
, and I want to use join
to obtain re=(1,2,3,4,5,6)
. However, the output is (1,2,3,(4,5,6))
, which is same as the result of a.append!(b)
. How could I modify my script?
Asked
Active
Viewed 22 times
1

Polly
- 603
- 3
- 13
-
Never used DolphinDB. What about union? https://www.dolphindb.com/help/FunctionsandCommands/FunctionReferences/u/union.html. – Allan Wind Jun 30 '23 at 01:48
2 Answers
2
The join
function alone won't return the desired result because it treats the second tuple b as a single element. You can use it within the reduce
function:
a1= (0,[1,2,3],4)
a2 = ([5,6], 7)
reduce(join, a2, a1)

Eva Gao
- 402
- 1
- 7
0
Both join
and union
can not work on tuples. You can try:
flatten((a, b))
to create a new tuple with elements ina
andb
;each(append!{a}, b)
to add every element inb
intoa
.

Hanwei Tang
- 413
- 3
- 10