Get number of elements of array in Julia – length() Method
Last Updated :
26 Mar, 2020
The length()
is an inbuilt function in julia which is used to return the number of elements present in the specified array.
Syntax: length(A::AbstractArray)
Parameters:
Returns: It returns the number of elements present in the specified array.
Example 1:
A = [ 5 , 10 , 15 , 20 ]
println(length(A))
B = [ 5 10 ; 15 20 ]
println(length(B))
C = cat([ 1 2 ; 3 4 ], [ 5 6 ; 7 8 ],
[ 9 10 ; 11 12 ], dims = 3 )
println(length(C))
|
Output:
Example 2:
A = [ 1 , 2 , 3 ];
println(length(A))
B = [ 2 4 ; 6 8 ; 10 12 ];
println(length(B))
C = cat([ 1 2 ; 3 4 ], [ 5 6 ; 7 8 ],
[ 9 10 ; 11 12 ], [ 13 14 ; 15 16 ], dims = 4 );
println(length(C))
|
Output:
Share your thoughts in the comments
Please Login to comment...