Get repetition of strings in Julia – ^ operator
The ^ is an operator in julia which is used to repeat the specified string with the specified number of times.
Syntax:
^(s::Union{AbstractString, AbstractChar}, n::Integer)
Parameters:
- s::Union{AbstractString, AbstractChar}: Specified strings or characters
- n::Integer: Specified integer
Returns: It returns a new repeated string.
Example 1:
Python
# Julia program to illustrate # the use of operator ^ # Get repetition of different strings println( "GFG " ^ 3 ) println( "GeekforGeeks " ^ 2 ) println( "abc " ^ 2 ) println( "a " ^ 4 ) |
Output:
GFG GFG GFG GeekforGeeks GeekforGeeks abc abc a a a a
Example 2:
Python
# Julia program to illustrate # the use of operator ^ # Get repetition of different strings println( "1-" ^ 3 ) println( "123 " ^ 2 ) println( "5& " ^ 2 ) println( "0 * 0 " ^ 4 ) |
Output:
1-1-1- 123 123 5& 5& 0*0 0*0 0*0 0*0
Please Login to comment...