Creating array with repeated elements in Julia - repeat() Method Last Updated : 26 Mar, 2020 Comments Improve Suggest changes Like Article Like Report The repeat() is an inbuilt function in julia which is used to construct an array by repeating the specified array elements with the specified number of times. Syntax: repeat(A::AbstractArray, counts::Integer...) or repeat(A::AbstractArray; inner, outer) or repeat(s::AbstractString, r::Integer) or repeat(c::AbstractChar, r::Integer) Parameters: A::AbstractArray: Specified array. counts::Integer: Specified number of times each element get repeated. inner: It says the repetition of individual element. outer: It says the repetition of whole slice. s::AbstractString: Specified string. r::Integer: Specified number of times each element get repeated. c::AbstractChar: Specified character. Returns: It returns a new constructed array. Example 1: Python # Julia program to illustrate # the use of Array repeat() method # Constructing an array by repeating # the specified 1D array with the # specified number of times. A = [1, 2, 3, 4]; println(repeat(A, 1)) # Constructing an array by repeating # the specified 1D array with the # specified number of times. B = [1, 2, 3, 4]; println(repeat(B, 1, 2)) # Constructing an array by repeating # the specified 2D array with the # specified number of times. C = [1 2; 3 4]; println(repeat(C, 2)) # Constructing an array by repeating # the specified 2D array with the # specified number of times. D = [1 2; 3 4]; println(repeat(D, 2, 2)) Output: Example 2: Python # Julia program to illustrate # the use of Array repeat() method # Constructing an array by repeating # the specified elements with the # specified inner value println(repeat(1:3, inner = 2)) # Constructing an array by repeating # the specified elements with the # specified outer value println(repeat(2:4, outer = 2)) # Constructing an array by repeating # the specified elements with the # specified inner and outer value println(repeat([5 10; 15 20], inner =(2, 1), outer =(1, 3))) Output: Example 3: Python # Julia program to illustrate # the use of Array repeat() method # Getting new string after repetition of # specified string or character println(repeat("GFG", 3)) println(repeat("GeeksforGeeks", 2)) println(repeat("a", 4)) println(repeat("A", 5)) Output: GFGGFGGFG GeeksforGeeksGeeksforGeeks aaaa AAAAA Comment More infoAdvertise with us Next Article Creating array with repeated elements in Julia - repeat() Method K Kanchan_Ray Follow Improve Article Tags : Julia Similar Reads Replacing elements of a collection in Julia - replace() and replace!() Methods The replace() is an inbuilt function in julia which is used to return a copy of the specified array with different types of replacement. These all operations are illustrated with below examples. Syntax: replace(A, old_new::Pair...; count::Integer) or replace(new::Function, A; count::Integer) Paramet 3 min read Get all array elements with true values in Julia | Array findall() Method The findall() is an inbuilt function in julia which is used to return a vector of indices or keys of the all true values from the specified array A. If such true values are not present in the array, return an empty array. Here values of index or key start from 1 i.e, for index of 1st element is 1, i 2 min read Reshaping array dimensions in Julia | Array reshape() Method The reshape() is an inbuilt function in julia which is used to return an array with the same data as the specified array, but with different specified dimension sizes. Syntax: reshape(A, dims) Parameters: A: Specified array. dims: Specified dimension. Returns: It returns an array with the same data 2 min read Representing the dimensions of array in Julia - Dims() Method The Dims() is an inbuilt function in julia which is used to represent the dimensions of the specified AbstractArray. Syntax: Dims(A) Parameters: A: Specified array Returns: It returns the represented dimensions of the specified AbstractArray. Example 1: Python # Julia program to illustrate # the use 1 min read Get repetition of a string in Julia - repeat() Method The repeat() is an inbuilt function in julia which is used to return a string which is the repetition of specified string with specified number of times. Syntax: repeat(String::AbstractString, r::Integer) Parameters: String: Specified string or character r::Integer: Specified number of times Returns 2 min read Like