Getting minimum elements in Julia – minimum() and minimum!() Methods
The minimum() is an inbuilt function in julia which is used to return minimum elements in different scenario.
Syntax:
minimum(f, itr)
or
minimum(itr)
or
minimum(A::AbstractArray; dims)
Parameters:
- f: Specified function.
- itr: Specified list of elements.
- A::AbstractArray: Specified array of different dimensions.
- dims: Specified dimensions.
Returns: It returns the minimum elements in different scenario.
Example:
Julia
println(minimum(length, [ "GFG" , "Geeks" , "GeeksforGeeks" ]))
println(minimum([ 5 , 10 , 15 , 20 ]))
A = [ 5 10 ; 15 20 ];
println(minimum(A, dims = 1 ))
println(minimum(A, dims = 2 ))
|
Output:
minimum!()
The minimum!() is an inbuilt function in julia which is used to calculate the minimum value of the specified array over the specified singleton dimensions.
Syntax: minimum!(r, A)
Parameters:
- r: Specified singleton dimensions.
- A: Specified array.
Returns: It returns the minimum value of the specified array over the specified singleton dimensions.
Example:
Julia
A = [ 5 10 ; 15 20 ];
println(minimum !([ 1 ; 1 ], A))
println(minimum !([ 1 1 ], A))
|
Output:
[5, 15]
[5 10]
Last Updated :
27 Dec, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...