:: [t] -> Int -package:perf

length returns the length of a finite list as an Int. It is an instance of the more general genericLength, the result type of which may be any kind of number.
>>> length []
0

>>> length ['a', 'b', 'c']
3

>>> length [1..]
* Hangs forever *
Number of dimensions
A version specialized to lists to avoid errors such as taking length of Maybe [a] instead of [a]. Such errors are hard to detect, because the type of elements of the list is not constrained.
Number of dimensions
>>> rank @Int [2,3,4]
3
Length of vector. Function doesn't evaluate its argument.
An implementation of toList for Corecursive fixed-points of XNor.
An unsafe implementation of fromList for Steppable fixed-points of XNor.
Returns the size/length of a finite structure as an Int. The default implementation just counts elements starting with the leftmost. Instances for structures that can compute the element count faster than via element-by-element counting, should provide a specialised implementation.

Examples

Basic usage:
>>> length []
0
>>> length ['a', 'b', 'c']
3

>>> length [1..]
* Hangs forever *
Returns the size/length of a finite structure as an Int. The default implementation just counts elements starting with the leftmost. Instances for structures that can compute the element count faster than via element-by-element counting, should provide a specialised implementation.

Examples

Basic usage:
>>> length []
0
>>> length ['a', 'b', 'c']
3

>>> length [1..]
* Hangs forever *
@since base-4.8.0.0
Returns the size/length of a finite structure as an Int. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.
The genericLength function is an overloaded version of length. In particular, instead of returning an Int, it returns any type which is an instance of Num. It is, however, less efficient than length.

Examples

>>> genericLength [1, 2, 3] :: Int
3

>>> genericLength [1, 2, 3] :: Float
3.0
Users should take care to pick a return type that is wide enough to contain the full length of the list. If the width is insufficient, the overflow behaviour will depend on the (+) implementation in the selected Num instance. The following example overflows because the actual list length of 200 lies outside of the Int8 range of -128..127.
>>> genericLength [1..200] :: Int8
-56
The genericLength function is an overloaded version of length. In particular, instead of returning an Int, it returns any type which is an instance of Num. It is, however, less efficient than length.
>>> genericLength [1, 2, 3] :: Int
3

>>> genericLength [1, 2, 3] :: Float
3.0
The genericLength function is an overloaded version of length. In particular, instead of returning an Int, it returns any type which is an instance of Num. It is, however, less efficient than length.
>>> genericLength [1, 2, 3] :: Int
3

>>> genericLength [1, 2, 3] :: Float
3.0
Users should take care to pick a return type that is wide enough to contain the full length of the list. If the width is insufficient, the overflow behaviour will depend on the (+) implementation in the selected Num instance. The following example overflows because the actual list length of 200 lies outside of the Int8 range of -128..127.
>>> genericLength [1..200] :: Int8
-56
Left associative length computation that is appropriate for types like Integer.
Right associative length computation that is appropriate for types like Peano number.
O(1) Yield the length of the vector
Assumed complexity: O(1) Yield the length of the vector.
Calculates a suitable logarithmic Bytesize for a given list.

Examples

>>> getLnBytesize ([1 .. 27] :: [Int])
4
>>> getLnBytesize  ([(1, 16), (5, 23), (2, 4), (3, 8), (0, 15) , (4, 42)] :: [(Int, Int)])
2
Default definition for norm that is based on Foldable class.