Zulip Chat Archive

Stream: new members

Topic: fin zip function


Patrick Thomas (Jun 26 2022 at 19:30):

Is there a way to fix this?

example
  {α β : Type} [decidable_eq α]
  {n : }
  (f : fin n  α)
  (g : fin n  β)
  (default : α  β) :
  α  β :=
fun x : α, if h :  m : fin n, f m = x then g m else default x

Patrick Thomas (Jun 26 2022 at 19:30):

Or do something similar?

Kevin Buzzard (Jun 26 2022 at 19:31):

What if there are two different m's with f(m)=x?

Eric Wieser (Jun 26 2022 at 19:31):

I think you want docs#nat.find to extract the m from the h

Patrick Thomas (Jun 26 2022 at 19:32):

Kevin Buzzard said:

What if there are two different m's with f(m)=x?

Yes, that is a good point. I should have added the condition that there are not.

Eric Wieser (Jun 26 2022 at 19:33):

docs#fintype.choose would also work if you add that condition

Patrick Thomas (Jun 26 2022 at 19:33):

Thank you!


Last updated: Dec 20 2023 at 11:08 UTC