Zulip Chat Archive

Stream: new members

Topic: List comprehension


Burkhardt Renz (Jan 22 2025 at 09:00):

Does Lean support syntactic sugar for list comprehension like Haskell?
If not, how to do list comprehension idiomatically in Lean?

Edward van de Meent (Jan 22 2025 at 10:25):

You can use docs#List.map , docs#List.foldl , docs#List.flatten and the whole shebang

Edward van de Meent (Jan 22 2025 at 10:27):

Alternatively, import docs#List.instMonad and use do notation

Edward van de Meent (Jan 22 2025 at 10:28):

Do note that unlike python and Haskell, lean does not use lazy evaluation


Last updated: May 02 2025 at 03:31 UTC