File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -366,6 +366,11 @@ Other minor additions
366
366
367
367
* Added infix declarations to ` Data.Product.∃-syntax ` and ` Data.Product.∄-syntax ` .
368
368
369
+ * Added new function to ` Data.List.Base ` :
370
+ ``` agda
371
+ unsnoc : List A → Maybe (List A × A)
372
+ ```
373
+
369
374
* Added new definitions to ` Function.Bundles ` :
370
375
``` agda
371
376
record Func : Set _
Original file line number Diff line number Diff line change @@ -344,7 +344,7 @@ infixr 5 _ʳ++_
344
344
_ʳ++_ : List A → List A → List A
345
345
_ʳ++_ = flip reverseAcc
346
346
347
- -- Snoc.
347
+ -- Snoc: Cons, but from the right .
348
348
349
349
infixl 6 _∷ʳ_
350
350
@@ -370,14 +370,18 @@ data InitLast {A : Set a} : List A → Set a where
370
370
[] : InitLast []
371
371
_∷ʳ′_ : (xs : List A) (x : A) → InitLast (xs ∷ʳ x)
372
372
373
-
374
-
375
373
initLast : (xs : List A) → InitLast xs
376
374
initLast [] = []
377
375
initLast (x ∷ xs) with initLast xs
378
376
... | [] = [] ∷ʳ′ x
379
377
... | ys ∷ʳ′ y = (x ∷ ys) ∷ʳ′ y
380
378
379
+ -- uncons, but from the right
380
+ unsnoc : List A → Maybe (List A × A)
381
+ unsnoc as with initLast as
382
+ ... | [] = nothing
383
+ ... | xs ∷ʳ′ x = just (xs , x)
384
+
381
385
------------------------------------------------------------------------
382
386
-- Splitting a list
383
387
You can’t perform that action at this time.
0 commit comments