length -package:bytestring -package:utf8-string -package:filepath -package:vector package:ghc -is:exact
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 length of the
FastString in characters
(lengthAtLeast xs n) = (length xs >= n)
(lengthAtMost xs n) = (length xs <= n)
(lengthExceeds xs n) = (length xs > n)
(lengthIs xs n) = (length xs == n)
(lengthIsNot xs n) = (length xs /= n)
(lengthLessThan xs n) == (length xs < n)
Encode the argument in it's full length. This is different from many
default binary instances which make no guarantee about the actual
encoding and might do things use variable length encoding.
atLength atLen atEnd ls n unravels list
ls to
position
n. Precisely:
atLength atLenPred atEndPred ls n
| n < 0 = atLenPred ls
| length ls < n = atEndPred (n - length ls)
| otherwise = atLenPred (drop n ls)
True if length xs == length ys
True if length xs <= length ys
True if length xs < length ys