r/programminghorror • • Sep 02 '26

Lean4 Finally solved Two Sum!

Somehow my code is so horrifying, Lean4 is able to evaluate it, the LSP says it works and the compiler gives an error. It is theoretically correct and the kernel accepts it, but the compiler isn't able to produce anything out of it. My awful code discovered a bug in Lean's compiler.

183 Upvotes

15 comments sorted by

View all comments

Show parent comment

2

u/NooneAtAll3 Sep 02 '26

by the way, have you tried experimenting with cpp-based syntax?

lean supports many styles, you don't have to only use python-esk whitespace-based nesting

1

u/swagnation77 Sep 02 '26

Never tried it but seems interesting. I'm still learning Lean so I have just been following convention. I don't really like Lean's default syntax so thanks for the tip!