Could someone explain how to understand this notation:
((a, b) → a) → a → [b] → a
((a, b) → a) → a → [b] → a
^^^^^^^^^^^^ ^ ^^^ ^
1 2 3 4
This is a function that takes three arguments (1) (2) (3) and returns a value of type a
(4):
a
b
reduce( (acc, x) => acc + x.length, 0, ["foo", "bar", "baz"]); //=> 9
// ^^^ ^ ^^^^^^^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^ ^
// a b a a [b] a
// ((a -> b) -> a ) -> a -> [b] -> a
In this case a
stands for the number
type and b
stands for the string
type.