RosettaCodeData/Task/Array-concatenation/Julia/array-concatenation.julia

10 lines
294 B
Text
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
a = [1,2,3]
b = [4,5,6]
2017-09-23 10:01:46 +02:00
ab = [a;b]
2013-06-05 21:47:54 +00:00
# the above bracket notation simply generates a call to vcat
2013-04-10 21:29:02 -07:00
ab = vcat(a,b)
2013-06-05 21:47:54 +00:00
# hcat is short for `horizontal concatenation`
ab = hcat(a,b) #ab -> 3x2 matrix
# the append!(a,b) method is mutating, appending `b` to `a`
append!(a,b) # a now equals [1,2,3,4,5,6]