:: [char] -> [char] -> [char] -package:hledger

(++) appends two lists, i.e.,
[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
If the first list is not finite, the result is the first list.

Performance considerations

This function takes linear time in the number of elements of the first list. Thus it is better to associate repeated applications of (++) to the right (which is the default behaviour): xs ++ (ys ++ zs) or simply xs ++ ys ++ zs, but not (xs ++ ys) ++ zs. For the same reason concat = foldr (++) [] has linear performance, while foldl (++) [] is prone to quadratic slowdown

Examples

>>> [1, 2, 3] ++ [4, 5, 6]
[1,2,3,4,5,6]
>>> [] ++ [1, 2, 3]
[1,2,3]
>>> [3, 2, 1] ++ []
[3,2,1]
tailDef [12] [] = [12]
tailDef [12] [1,3,4] = [3,4]
Append two lists, i.e.,
[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
If the first list is not finite, the result is the first list. WARNING: This function takes linear time in the number of elements of the first list.
Returns the shorter one of two lists. It works also for infinite lists as much as possible. E.g.
>>> shorterList (shorterList (repeat 'a') (repeat 'b')) "abc"
"abc"
The trick is, that the skeleton of the resulting list is constructed using zipWith without touching the elements. The contents is then computed (only) if requested.
Append two lists, i.e.,
[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
If the first list is not finite, the result is the first list.
Fair 2-way interleaving.
Lazily interleaves two lists, switching between elements of the two. Union/sum of the elements in the lists.
[x,y,z,...] +| [a,b,c,...]  =  [x,a,y,b,z,c,...]
Tail function (safe). Returns a default list on empty lists. O(1).
init, safe. O(n).
merges elements from two lists into one list in an alternating way
interleave [0,1,2,3] [10,11,12,13] == [0,10,1,11,2,12,3,13]
(⧺) = (++) U+29FA, DOUBLE PLUS
Make a list as long as another one
\(Shape xs) (List ys) -> Match.take xs ys == List.take (length xs) ys
Drop as many elements as the first list is long
\(Shape xs) (List ys) -> Match.drop xs ys == List.drop (length xs) ys
\(Shape xs) (List ys) -> Match.take xs ys ++ Match.drop xs ys == ys
\(Shape xs) (List ys) -> Match.takeRev xs ys == reverse (Match.take xs (reverse ys))
\(Shape xs) (List ys) -> Match.dropRev xs ys == reverse (Match.drop xs (reverse ys))
Chooses between a compiled action and an interpreted action based on the configured default.
Nondeterministically choose between two computations.
(m <|> n) >>= k = (m >>= k) <|> (n >>= k)
(m <|> n) <|> o = m <|> (n <|> o)
empty <|> m = m
m <|> empty = m