query
On this page

hasPrefix

lib.lists.hasPrefix

Docs pulled from | This Revision | 11 minutes ago


Whether the first list is a prefix of the second list.

Inputs

list1

1. Function argument

list2

2. Function argument

Type

hasPrefix :: [a] -> [a] -> bool

Examples

lib.lists.hasPrefix usage example

hasPrefix [ 1 2 ] [ 1 2 3 4 ]
=> true
hasPrefix [ 0 1 ] [ 1 2 3 4 ]
=> false

Noogle detected

Implementation

The following is the current implementation of this function.

hasPrefix =
    list1:
    list2:
    take (length list1) list2 == list1;