Skip to content

Commit e139d4e

Browse files
committed
Make head O(1)
By using index rather than uncons.
1 parent 3159f7e commit e139d4e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Data/Array.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ insertBy cmp x ys =
219219
-- |
220220
-- | Running time: `O(1)`.
221221
head :: forall a. Array a -> Maybe a
222-
head = uncons' (const Nothing) (\x _ -> Just x)
222+
head xs = xs !! 0
223223

224224
-- | Get the last element in an array, or `Nothing` if the array is empty
225225
-- |

0 commit comments

Comments
 (0)