Zulip Chat Archive
Stream: Is there code for X?
Topic: List.sort
Violeta Hernández (Aug 22 2024 at 03:13):
I do know docs#List.mergeSort exists, so my question isn't that but rather: is that the preferred spelling for talking about sorting a list?
Violeta Hernández (Aug 22 2024 at 03:34):
Oops, this might have been an #XY. Just found about docs#Finset.sort
Violeta Hernández (Aug 22 2024 at 03:45):
Another question. Do we have l.toFinset.toList ~ l
for Nodup l
?
Daniel Weber (Aug 22 2024 at 05:09):
@loogle List.Nodup, List.toFinset
loogle (Aug 22 2024 at 05:09):
:search: List.toFinset_eq, Finset.exists_list_nodup_eq, and 14 more
Daniel Weber (Aug 22 2024 at 05:10):
This should be immediate from docs#List.perm_of_nodup_nodup_toFinset_eq
Violeta Hernández (Aug 22 2024 at 05:11):
Indeed
import Mathlib.Data.Finset.Basic
theorem List.toFinset_toList [DecidableEq α] {s : List α} (hs : s.Nodup) :
s.toFinset.toList.Perm s :=
List.perm_of_nodup_nodup_toFinset_eq (Finset.nodup_toList _) hs (Finset.toList_toFinset _)
Last updated: May 02 2025 at 03:31 UTC