insert package:base

The insert function takes an element and a list and inserts the element into the list at the first position where it is less than or equal to the next element. In particular, if the list is sorted before the call, the result will also be sorted. It is a special case of insertBy, which allows the programmer to supply their own comparison function.

Examples

>>> insert (-1) [1, 2, 3]
[-1,1,2,3]
>>> insert 'd' "abcefg"
"abcdefg"
>>> insert 4 [1, 2, 3, 5, 6, 7]
[1,2,3,4,5,6,7]
insert x xs inserts x into the last position in xs where it is still less than or equal to the next element. In particular, if the list is sorted beforehand, the result will also be sorted.
The non-overloaded version of insert.

Examples

>>> insertBy (\x y -> compare (length x) (length y)) [1, 2] [[1], [1, 2, 3], [1, 2, 3, 4]]
[[1],[1,2],[1,2,3],[1,2,3,4]]
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.
Insert a scalar at the given position in a vector.