diff options
| author | Andreas Grois <andi@grois.info> | 2024-09-09 08:54:44 +0200 |
|---|---|---|
| committer | Andreas Grois <andi@grois.info> | 2024-09-09 08:54:44 +0200 |
| commit | 6718bbdbc6997a7f8acfa0b2622afa04179a7f53 (patch) | |
| tree | 7de6d3608587e4c998b8fd1261f2e5d37c7ea525 /Common/NonEmptyList.lean | |
| parent | 7e50958adb75487cef49807b1a515591544cf6ac (diff) | |
Continue Day10 Part2
Diffstat (limited to 'Common/NonEmptyList.lean')
| -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} |
