x=[“j”,“u”,“l”,“i”,“a”]
such as: string?(x) into “julia”
x=[“j”,“u”,“l”,“i”,“a”]
such as: string?(x) into “julia”
Hi there,
the function you are looking for is called join
.
julia> x=["j","u","l","i","a"]
5-element Array{String,1}:
"j"
"u"
"l"
"i"
"a"
julia> join(x)
"julia"
Alternatively, string(x...)
and reduce(*,x)
work as well.
There is also join
:
help?> join(x)
join([io::IO,] strings, delim, [last])
Join an array of strings into a single string, inserting the given
delimiter between adjacent strings. If last is given, it will be
used instead of delim between the last two strings. If io is
given, the result is written to io rather than returned as as
a String.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> join(["apples", "bananas", "pineapples"], ", ", " and ")
"apples, bananas and pineapples"
julia> join(["j", "u", "l", "i", "a"])
"julia"
Sorry, @fredrikekre I updated my post to include join
before you posted yours
BTW, for better readability use backticks ` short code goes here `
or triple backticks ``` longer codeblock goes here ```
to enable syntax highlighting etc. for you code.
You need to interpolate global variables with $ when benchmarking with BenchmarkTooks.jl
An extra use case of join(x)
over the use of the splat operator for the string concatenation is that join(x,',')
can also let you include a delimiter (separator)