Haskell lists are implemented as linked lists, which means that access to an arbitrary i-th element is in O(i). In normal mode, the binary search version elemfor lists will take longer than the standard version (see @DanielFischer Note below).
You might want to use another container, for example, Data.Set or Data.Map , which are implemented as a balanced binary tree that gives you O(log n)access time (where nis the number of elements in the map / set).
source
share