Skip to content

Instantly share code, notes, and snippets.

@thelissimus
Created August 7, 2025 06:29
Show Gist options
  • Select an option

  • Save thelissimus/b8937b169cc0c093a569235c78de373b to your computer and use it in GitHub Desktop.

Select an option

Save thelissimus/b8937b169cc0c093a569235c78de373b to your computer and use it in GitHub Desktop.
def headOpt (xs : List α) : Option α :=
match xs with
| x :: _ => some x
| [] => none -- need to introduce `Option` to handle the empty list case
def head (xs : List α) (h : xs ≠ []) : α :=
match xs with
| x :: _ => x
-- no need to handle empty list case as it is impossible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment