Zulip Chat Archive

Stream: new members

Topic: is there a way to do multiple `let mut` in 1 line?


Alok Singh (Jan 04 2024 at 19:09):

Example spelling

def f :=
  let (mut x, mut y) = (1,2)

Philipp (Jan 04 2024 at 19:13):

I think let mut is only allowed in do notation.

In that case the following works:

def f : Nat := Id.run do
  let mut (x, y) := (1, 2)
  x

Also see https://lean-lang.org/functional_programming_in_lean/monad-transformers/do.html?highlight=let%20mut#mutable-variables

Alok Singh (Jan 08 2024 at 08:31):

thanks!


Last updated: May 02 2025 at 03:31 UTC