From 6718bbdbc6997a7f8acfa0b2622afa04179a7f53 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Mon, 9 Sep 2024 08:54:44 +0200 Subject: Continue Day10 Part2 --- Common/NonEmptyList.lean | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Common/NonEmptyList.lean (limited to 'Common/NonEmptyList.lean') 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} -- cgit v1.2.3