Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenation of the strings vector in Clojure

I would like to concatenate strings stored in a vector. For example if I have ["a" "b" "c"] in the vector I would like to get as a result "abc".

like image 740
Adam Sznajder Avatar asked Jul 09 '12 13:07

Adam Sznajder


People also ask

How do you concatenate strings?

Concatenation is the process of appending one string to the end of another string. You concatenate strings by using the + operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.

How do you define a string in Clojure?

In Clojure, strings are text between a pair of " (double quote) characters. The ' (single quote) isn't used to express strings in Clojure. When we want to use double quotes within a string, they must be escaped by \ (backslash).

What is string concatenation with example?

In formal language theory and computer programming, string concatenation is the operation of joining character strings end-to-end. For example, the concatenation of "snow" and "ball" is "snowball". In certain formalisations of concatenation theory, also called string theory, string concatenation is a primitive notion.


1 Answers

You can use apply with the str function:

(apply str ["a" "b" "c"])
like image 101
mtyaka Avatar answered Sep 19 '22 15:09

mtyaka