- 1 and 2: Both achieve the same thing. The difference is that you can use the latter to reduce code size if and when is applicable.
- 3: Execution speed may vary. For example
array mappingis much slower than functorarray mappingis slower than functor if we use an edge case of Rafael's example codeabove.
Huge array - Edge case Functor vs Function
- 4: Discussion on functors usually gets formal and theoretical. The reason for this is that, like all functional programming techniques, functors originate from mathematics, in this case category theory. Functors are defined as:
"morphisms between categories"i.e a functor is an entity that defines the behavior of "fmap" that, given a value and function "morphism", maps said function onto a value of certain type "category" and generates a new functor. So an array is a Functor, because the array can be mapped over.
Simply put, a functor is a value (an object in javascript) that:
- Has a map method that expects a function
- The expected function can return any kind of value
- The map function will return another functor of the same type (as the original functor)
- 1 and 2: Both achieve the same thing. The difference is that you can use the latter to reduce code size if and when is applicable.
- 3: Execution speed may vary. For example
array mappingis much slower than functor if we use Rafael's example code. - 4: Discussion on functors usually gets formal and theoretical. The reason for this is that, like all functional programming techniques, functors originate from mathematics, in this case category theory. Functors are defined as:
"morphisms between categories"i.e a functor is an entity that defines the behavior of "fmap" that, given a value and function "morphism", maps said function onto a value of certain type "category" and generates a new functor. So an array is a Functor, because the array can be mapped over.
Simply put, a functor is a value (an object in javascript) that:
- Has a map method that expects a function
- The expected function can return any kind of value
- The map function will return another functor of the same type (as the original functor)
- 1 and 2: Both achieve the same thing. The difference is that you can use the latter to reduce code size if and when is applicable.
- 3: Execution speed may vary. For example
array mappingis slower than functor if we use an edge case of Rafael's example above.
Huge array - Edge case Functor vs Function
- 4: Discussion on functors usually gets formal and theoretical. The reason for this is that, like all functional programming techniques, functors originate from mathematics, in this case category theory. Functors are defined as:
"morphisms between categories"i.e a functor is an entity that defines the behavior of "fmap" that, given a value and function "morphism", maps said function onto a value of certain type "category" and generates a new functor. So an array is a Functor, because the array can be mapped over.
Simply put, a functor is a value (an object in javascript) that:
- Has a map method that expects a function
- The expected function can return any kind of value
- The map function will return another functor of the same type (as the original functor)
- 1 and 2: Both achieve the same thing. The difference is that you can use the latter to reduce code size if and when is applicable.
- 3: Execution speed may vary. For example
array mappingis much slower than functor if we use Rafael's example code.
- 4: Discussion on functors usually gets formal and theoretical. The reason for this is that, like all functional programming techniques, functors originate from mathematics, in this case category theory. Functors are defined as:
"morphisms between categories"i.e a functor is an entity that defines the behavior of "fmap" that, given a value and function "morphism", maps said function onto a value of certain type "category" and generates a new functor. So an array is a Functor, because the array can be mapped over.
Simply put, a functor is a value (an object in javascript) that:
- Has a map method that expects a function
- The expected function can return any kind of value
- The map function will return another functor of the same type (as the original functor)
- 1 and 2: Both achieve the same thing. The difference is that you can use the latter to reduce code size if and when is applicable.
- 3: Execution speed may vary. For example
array mappingis much slower than functor if we use Rafael's example code.
- 4: Discussion on functors usually gets formal and theoretical. The reason for this is that, like all functional programming techniques, functors originate from mathematics, in this case category theory. Functors are defined as:
"morphisms between categories"i.e a functor is an entity that defines the behavior of "fmap" that, given a value and function "morphism", maps said function onto a value of certain type "category" and generates a new functor. So an array is a Functor, because the array can be mapped over.
Simply put, a functor is a value (an object in javascript) that:
- Has a map method that expects a function
- The expected function can return any kind of value
- The map function will return another functor of the same type (as the original functor)
- 1 and 2: Both achieve the same thing. The difference is that you can use the latter to reduce code size if and when is applicable.
- 3: Execution speed may vary. For example
array mappingis much slower than functor if we use Rafael's example code. - 4: Discussion on functors usually gets formal and theoretical. The reason for this is that, like all functional programming techniques, functors originate from mathematics, in this case category theory. Functors are defined as:
"morphisms between categories"i.e a functor is an entity that defines the behavior of "fmap" that, given a value and function "morphism", maps said function onto a value of certain type "category" and generates a new functor. So an array is a Functor, because the array can be mapped over.
Simply put, a functor is a value (an object in javascript) that:
- Has a map method that expects a function
- The expected function can return any kind of value
- The map function will return another functor of the same type (as the original functor)
- 1 and 2: Both achieve the same thing. The difference is that you can use the latter to reduce code size if and when is applicable.
- 3: Execution speed may vary. For example
array mappingis much slower than functor if we use Rafael's example code.
- 4: Discussion on functors usually gets formal and theoretical. The reason for this is that, like all functional programming techniques, functors originate from mathematics, in this case category theory. Functors are defined as:
"morphisms between categories"i.e a functor is an entity that defines the behavior of "fmap" that, given a value and function "morphism", maps said function onto a value of certain type "category" and generates a new functor. So an array is a Functor, because the array can be mapped over.
Simply put, a functor is a value (an object in javascript) that:
- Has a map method that expects a function
- The expected function can return any kind of value
- The map function will return another functor of the same type (as the original functor)
- 1 and 2: Both achieve the same thing. The difference is that you can use the latter to reduce code size if and when is applicable.
- 3: Execution speed may vary. For example
array mappingis much slower than functor if we use Rafael's example code. - 4: Discussion on functors usually gets formal and theoretical. The reason for this is that, like all functional programming techniques, functors originate from mathematics, in this case category theory. Functors are defined as:
"morphisms between categories"i.e a functor is an entity that defines the behavior of "fmap" that, given a value and function "morphism", maps said function onto a value of certain type "category" and generates a new functor. So an array is a Functor, because the array can be mapped over.
Simply put, a functor is a value (an object in javascript) that:
- Has a map method that expects a function
- The expected function can return any kind of value
- The map function will return another functor of the same type (as the original functor)
- 1 and 2: Both achieve the same thing. The difference is that you can use the latter to reduce code size if and when is applicable.
- 3: Execution speed may vary. For example
array mappingis much slower than functor if we use Rafael's example code.
- 4: Discussion on functors usually gets formal and theoretical. The reason for this is that, like all functional programming techniques, functors originate from mathematics, in this case category theory. Functors are defined as:
"morphisms between categories"i.e a functor is an entity that defines the behavior of "fmap" that, given a value and function "morphism", maps said function onto a value of certain type "category" and generates a new functor. So an array is a Functor, because the array can be mapped over.
Simply put, a functor is a value (an object in javascript) that:
- Has a map method that expects a function
- The expected function can return any kind of value
- The map function will return another functor of the same type (as the original functor)