commonPrefix
lib.lists.commonPrefix
Docs pulled from | This Revision | 18 minutes ago
Nixpkgs manual
The common prefix of two lists.
Inputs
list1-
1. Function argument
list2-
2. Function argument
Type
commonPrefix :: [a] -> [a] -> [a]
Examples
lib.lists.commonPrefix usage example
commonPrefix [ 1 2 3 4 5 6 ] [ 1 2 4 8 ]
=> [ 1 2 ]
commonPrefix [ 1 2 3 ] [ 1 2 3 4 5 ]
=> [ 1 2 3 ]
commonPrefix [ 1 2 3 ] [ 4 5 6 ]
=> [ ]
Noogle detected
Implementation
The following is the current implementation of this function.
commonPrefix = list1: list2: take (commonPrefixLength list1 list2) list1;