Getting first and last set of elements in Julia – front() and tail() Methods
Last Updated :
26 Mar, 2020
The front()
is an inbuilt function in julia which is used to return a tuple consisting of all but the last component of x, where x is the specified tuple.
Syntax: front(x::Tuple)::Tuple
Parameters:
- x::Tuple: Specified tuple.
Returns: It returns a tuple consisting of all but the last component of x, where x is the specified tuple.
Example:
println(Base.front(( 1 , 2 , 3 )))
println(Base.front(( 2 , 4 , 6 , 8 )))
println(Base.front(( 3 , 5 )))
|
Output:
(1, 2)
(2, 4, 6)
(3, )
The tail()
is an inbuilt function in julia which is used to return a tuple consisting of all but the first component of x, where x is the specified tuple.
Syntax: tail(x::Tuple)::Tuple
Parameters:
- x::Tuple: Specified tuple.
Returns: It returns a tuple consisting of all but the first component of x, where x is the specified tuple.
Example:
println(Base.tail(( 1 , 2 , 3 )))
println(Base.tail(( 2 , 4 , 6 , 8 )))
println(Base.tail(( 3 , 5 )))
|
Output:
(2, 3)
(4, 6, 8)
(5, )
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...