The reverse()
is an inbuilt function in julia which is used to reverse the specified vector v from start to stop.
Syntax:
reverse(v, start, stop)
or
reverse(A; dims::Integer)
Parameters:
- v: Specified vector.
- start: Specified starting value.
- stop: Specified stopping value.
- A: Specified array.
- dims::Integer: Specified dimensions.
Returns: It returns a reversed copy of the vector.
Example 1:
A = Vector( 2 : 8 )
println(reverse(A))
println(reverse(A, 3 , 6 ))
println(reverse(A, 7 , 4 ))
|
Output:
[8, 7, 6, 5, 4, 3, 2]
[2, 3, 7, 6, 5, 4, 8]
[2, 3, 4, 5, 6, 7, 8]
Example 2:
A = [ 5 10 ; 15 20 ]
println(reverse(A, dims = 1 ))
println(reverse(A, dims = 2 ))
|
Output:

reverse!()
The reverse!()
is an inbuilt function in julia which is In-place version of reverse() function.
Syntax:
reverse!(v, start, stop)
Parameters:
- v: Specified vector.
- start: Specified starting value.
- stop: Specified stopping value.
Returns: It returns a reversed copy of the vector.
Example:
A = Vector( 2 : 8 )
println(reverse !(A))
println(reverse !(A, 3 , 6 ))
|
Output:
[8, 7, 6, 5, 4, 3, 2]
[8, 7, 3, 4, 5, 6, 2]
reverseind
The reverseind()
is an inbuilt function in julia which is used to return the corresponding index in v so that v[reverseind(v, i)] == reverse(v)[i], where i is the given index.
Syntax:
reverseind(v, i)
Parameters:
- v: Specified string.
- i: Specified index.
Returns: It returns the corresponding index in v so that v[reverseind(v, i)] == reverse(v)[i].
Example:
V = reverse( "Geeks" )
for i in 1 :length(r)
print (V[reverseind( "Geeks" , i)])
end
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
01 Apr, 2020
Like Article
Save Article