News for hackers. Stuff that matters.
Re:Ask HN: What is the most beautiful piece of code you've e... by estomagordo on Monday October 28, 2019 @05:14AM (#21375385)
For Python, we don't need to supply the optional initializer 1. And reduce resides in the functools namespace (much like mul is in operator). I assume we're not talking about that peculiar dialect of Python that is no longer supported a few months from now.
Re:Ask HN: What is the most beautiful piece of code you've e... by messe on Monday October 28, 2019 @07:03AM (#21375866)
Not only that but in python 3.8, it can be written:

    def factorial(n):
        return math.prod(range(1,n+1))
Re:Ask HN: What is the most beautiful piece of code you've e... by estomagordo on Monday October 28, 2019 @07:53AM (#21376075)
Nice!
Re:Ask HN: What is the most beautiful piece of code you've e... by cakoose on Monday October 28, 2019 @05:07PM (#21381681)
> For Python, we don't need to supply the optional initializer 1.

Without the initializer, factorial(0) doesn't work.