Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a last function for lists #138

Open
heueristik opened this issue Nov 6, 2024 · 2 comments · May be fixed by #139
Open

Provide a last function for lists #138

heueristik opened this issue Nov 6, 2024 · 2 comments · May be fixed by #139

Comments

@heueristik
Copy link

There is a head function

head {A} (defaultValue : A) (list : List A) : A :=
  case list of
    | x :: _ := x
    | nil := defaultValue;

but no

last {A} (defaultValue : A) (list : List A) : A :=
  head@{
    defaultValue;
    list := reverse list;
  };
@mariari
Copy link
Member

mariari commented Nov 7, 2024

#139 fixes this issue

@mariari mariari linked a pull request Nov 7, 2024 that will close this issue
@lukaszcz
Copy link
Contributor

I don't think we should have last. There are few legitimate use-cases for it. It's most often used incorrectly by beginners when they try to use lists as if they were arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants