diff options
Diffstat (limited to 'Common')
| -rw-r--r-- | Common/NonEmptyList.lean | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Common/NonEmptyList.lean b/Common/NonEmptyList.lean new file mode 100644 index 0000000..786e192 --- /dev/null +++ b/Common/NonEmptyList.lean @@ -0,0 +1,11 @@ +structure NonEmptyList (α : Type) where + head : α + tail : List α + +namespace NonEmptyList +def toList (l : NonEmptyList α) : List α := + l.head :: l.tail + +def ofList (l : List α) (_ : ¬l.isEmpty) : NonEmptyList α := + match l with + | head :: tail => {head, tail} |
