3 ms·
I've tried in Rust, and it requires a return definition, as do most mainstream functional languages. Also, mainstream functional languages aren't truly mainstr
by fny 9y ago
I've tried in Rust, and it requires a return definition, as do most mainstream functional languages.
Also, mainstream functional languages aren't truly mainstream: I'd struggle to find devs who could help me in consulting gigs.
- igouy 9y agolet rec factorial n = if n = 0 || n = 1 then 1 else n * factorial (n - 1) F#
- mrkgnao 9y agoHaskell: factorial n = if n < 2 then 1 else n * factorial (n - 1) I think the OCaml version will look almost exactly like the F# one.
- mrkgnao 9y agoI'm pretty sure that's just "administrative" and imposed by the syntax (e.g. think Java/C++ function declaration syntax), instead of being something the compiler can't infer. Thanks for clearing this up, though.
- steveklabnik 9y agoIt was a design decision, yes. We could infer them if we wanted to, but we don't.