File tree Expand file tree Collapse file tree 2 files changed +144
-125
lines changed Expand file tree Collapse file tree 2 files changed +144
-125
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ module Data.Array
4949 , tail
5050 , init
5151 , uncons
52+ , unsnoc
5253
5354 , (!!), index
5455 , elemIndex
@@ -272,6 +273,12 @@ foreign import uncons'
272273 -> Array a
273274 -> b
274275
276+ -- | Break an array into its last element and all preceding elements.
277+ -- |
278+ -- | Running time: `O(n)` where `n` is the length of the array
279+ unsnoc :: forall a . Array a -> Maybe { init :: Array a , last :: a }
280+ unsnoc xs = { init: _, last: _ } <$> init xs <*> last xs
281+
275282-- ------------------------------------------------------------------------------
276283-- Indexed operations ----------------------------------------------------------
277284-- ------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments