Yes, you can do that in F#. (You probably know this, but for the sake of onlookers) it is called point-free notation. It can be handy for small functions like this. But I noticed when I use it too much, my code can become hard to understand.
Especially for code examples, I rarely use it because it can confuse readers.
Tuesday
Product of Array Items (7 KYU):
Calculate the product of all elements in an array.
CodeWars
A simple aggregation of data (using
reduce
) worked like a charm.C# answer.
F#
I probably wouldn't define a separate function for this in actual code.
Does F# require you to name the
arr
parameter explicitly or can you simply do the following:I've been curious about F# for some time but haven't really done a deep dive.
Yes, you can do that in F#. (You probably know this, but for the sake of onlookers) it is called point-free notation. It can be handy for small functions like this. But I noticed when I use it too much, my code can become hard to understand.
Especially for code examples, I rarely use it because it can confuse readers.
JavaScript
Haskell:
Common Lisp
as
*
in Common Lisp can take as many arguments as you like...Python!
Go
I decided to not use reduce so that I could return early if I hit a zero.
Javascript
Rust