Questions tagged [concatenation]

Joining of two or more sequences into a single sequence.

Concatenation refers to the joining of two or more elements into a single element.

In programming, this can refer to

  • concatenation, which joins multiple strings into a single string
  • concatenation, where one or more arrays are combined (mostly appended) to make a new array
  • specific concatenation functions that combine elements along a specified dimension (horizontally, or vertically for example), replicate and tile existing elements, and so forth.
12037 questions
174
votes
8 answers

Adding two Java 8 streams, or an extra element to a stream

I can add streams or extra elements, like this: Stream stream = Stream.concat(stream1, Stream.concat(stream2, Stream.of(element)); And I can add new stuff as I go, like this: Stream stream = Stream.concat( Stream.concat( …
Marcelo Glasberg
  • 29,013
  • 23
  • 109
  • 133
169
votes
5 answers

R - Concatenate two dataframes?

Given two dataframes a and b: > a a b c 1 -0.2246894 -1.48167912 -1.65099363 2 0.5559320 -0.87898575 -0.15634590 3 1.8469466 -0.01487524 -0.53098215 4 -0.6875051 0.23880967 0.01824621 5 -0.6735163 0.75485292 …
Darren J. Fitzpatrick
  • 7,159
  • 14
  • 45
  • 49
166
votes
9 answers

Prepend text to beginning of string

What is the fastest method, to add a new value at the beginning of a string?
mate64
  • 9,876
  • 17
  • 64
  • 96
161
votes
7 answers

Difference(s) between merge() and concat() in pandas

What's the essential difference(s) between pd.DataFrame.merge() and pd.concat()? So far, this is what I found, please comment on how complete and accurate my understanding is: .merge() can only use columns (plus row-indices) and it is semantically…
WindChimes
  • 2,955
  • 4
  • 25
  • 26
157
votes
9 answers

Concatenating string and integer in Python

In Python say you have s = "string" i = 0 print s + i will give you error, so you write print s + str(i) to not get error. I think this is quite a clumsy way to handle int and string concatenation. Even Java does not need explicit casting to…
specialscope
  • 4,188
  • 3
  • 24
  • 22
154
votes
5 answers

Is there any haskell function to concatenate list with separator?

Is there a function to concatenate elements of a list with a separator? For example: > foobar " " ["is","there","such","a","function","?"] ["is there such a function ?"] Thanks for any reply!
Fopa Léon Constantin
  • 11,863
  • 8
  • 48
  • 82
149
votes
4 answers

MySQL Results as comma separated list

I need to run a query like: SELECT p.id, p.name, (SELECT name FROM sites s WHERE s.id = p.site_id) AS site_list FROM publications p But I'd like the sub-select to return a comma separated list, instead of a column of…
Glen Solsberry
  • 11,960
  • 15
  • 69
  • 94
145
votes
13 answers

In Python, what is the difference between ".append()" and "+= []"?

What is the difference between: some_list1 = [] some_list1.append("something") and some_list2 = [] some_list2 += ["something"]
Nope
  • 34,682
  • 42
  • 94
  • 119
142
votes
4 answers

String concatenation does not work in SQLite

I am trying to execute a SQlite replace function, but use another field in the function. select locationname + '

' from location; In this snip, the result is a list of 0s. I would have expected a string with the text from locationname and the…

Ian Vink
  • 66,960
  • 104
  • 341
  • 555
139
votes
2 answers

What does ## (double hash) do in a preprocessor directive?

#define DEFINE_STAT(Stat) \ struct FThreadSafeStaticStat StatPtr_##Stat; The above line is take from Unreal 4, and I know I could ask it over on the unreal forums, but I think this is a general C++ question that warrants being asked…
DavidColson
  • 8,387
  • 9
  • 37
  • 50
137
votes
4 answers

ffmpeg concat: "Unsafe file name"

Trying to convert a bunch of mts-files into a big mp4-file: stephan@rechenmonster:/mnt/backupsystem/archive2/Videos/20151222/PRIVATE/AVCHD/BDMV$ ~/bin/ffmpeg-git-20160817-64bit-static/ffmpeg -v info -f concat -i <(find STREAM -name '*' -printf "file…
sers
  • 3,139
  • 3
  • 20
  • 28
137
votes
7 answers

Logger slf4j advantages of formatting with {} instead of string concatenation

Is there any advantage of using {} instead of string concatenation? An example from slf4j logger.debug("Temperature set to {}. Old temperature was {}.", t, oldT); instead of logger.debug("Temperature set to"+ t + ". Old temperature was " +…
Hernán Eche
  • 6,529
  • 12
  • 51
  • 76
136
votes
1 answer

Append an array to another array in JavaScript

This question is an exact duplicate of: How to append an array to an existing JavaScript Array? How do you append an array to another array in JavaScript? Other ways that a person might word this question: Add an array to another Concat /…
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258
133
votes
7 answers

Concatenate two string literals

I am reading Accelerated C++ by Koenig. He writes that "the new idea is that we can use + to concatenate a string and a string literal - or, for that matter, two strings (but not two string literals). Fine, this makes sense I suppose. Now onto two…
Arthur Collé
  • 2,541
  • 5
  • 27
  • 39
133
votes
6 answers

Concatenate strings in Less

I think this is not possible, but I thought I ask in case there is a way. The idea is that I have a variable for path to web resource folder: @root: "../img/"; @file: "test.css"; @url: @root@file; .px { background-image: url(@url); } I get…
juminoz
  • 3,168
  • 7
  • 35
  • 52