Zulip Chat Archive

Stream: Is there code for X?

Topic: last n elements of a list


Rob Lewis (Apr 21 2020 at 08:36):

I'm very surprised I can't find this -- is there a function ℕ → list _ → list _ that gets the last n elements of the list? I don't care about the behavior when n is too big.

Mario Carneiro (Apr 21 2020 at 08:37):

list.drop

Kenny Lau (Apr 21 2020 at 08:38):

list.drop (list.length L - n) L

Rob Lewis (Apr 21 2020 at 08:40):

That'll do, thanks!

Kevin Buzzard (Apr 21 2020 at 09:17):

My student Ellen Arlt needed a bunch of things about lists which she couldn't find in data.list.basic. Some of what she needed is here: https://github.com/ImperialCollegeLondon/dots_and_boxes/blob/master/src/sle/lemmas.lean . My impression was that there are some easy holes to be filled here, especially with regards to nth_le

Marc Huisinga (Apr 21 2020 at 09:23):

is the repo private?

Kevin Buzzard (Apr 21 2020 at 09:34):

Oh rofl it might be :-)

Kevin Buzzard (Apr 21 2020 at 09:34):

It's about 20 lemmas which should be in data.list.basic

Mario Carneiro (Apr 21 2020 at 09:34):

you could put them in a gist if you don't want to make the repo public

Mario Carneiro (Apr 21 2020 at 09:35):

(or a PR :smile: )


Last updated: Dec 20 2023 at 11:08 UTC