2 ms·
I find both Haskell's `fac n = product [1..n]` and F# `let factorial n = [1..n] |> List.reduce ()` more readable and easier to comprehend. You could say using `
by tasuki 2y ago
I find both Haskell's `fac n = product [1..n]` and F# `let factorial n = [1..n] |> List.reduce ()` more readable and easier to comprehend. You could say using `product` is cheating, but `fac n = fold () [1..n]` definitely isn't!
Your idiomatic Python version uses three variables, two of which mutate. I'm a simple man - go easy on me please! The `n + 1` took me a while to figure out too.