Contact/support | Changelog

Nice finite lists in Agda

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module RecursivePatterns where

open import Data.Bool
open import Data.List using (List ; [] ; __)

infixr 6 _,_

pattern [   xs    = xs
pattern _,_ hd tl = hd  tl
pattern _] a      = a  []

tail :  {A : Set} (xs : List A)  List A
tail []          = []
tail ([ a ])     = []
tail ([ a , b ]) = [ b ]
tail ([ a , b , x , d , e , f ]) = [ b , x , d , e , f ]
tail (hd  tl) = tl