Top "Higher-order-functions" questions

Higher-order functions are functions which either take functions as arguments or return them as output (or both).

How to use ES6 Fat Arrow to .filter() an array of objects

I'm trying to use ES6 arrow function with .filter to return adults (Jack & Jill). It appears I cannot use …

javascript ecmascript-6 higher-order-functions
How can I explode and trim whitespace?

For example, I would like to create an array from the elements in this string: $str = 'red, green, blue ,orange'; …

php explode trim higher-order-functions
How to filter an array by a condition

I have an array like this: array("a" => 2, "b" => 4, "c" => 2, "d" => 5, "e" => 6, "f" => 2) Now …

php arrays filter higher-order-functions
difference between foldLeft and reduceLeft in Scala

I have learned the basic difference between foldLeft and reduceLeft foldLeft: initial value has to be passed reduceLeft: takes first …

scala functional-programming fold higher-order-functions
Why is Haskell (GHC) so darn fast?

Haskell (with the GHC compiler) is a lot faster than you'd expect. Used correctly, it can get close-ish to low-level …

performance haskell ghc higher-order-functions lambda-calculus
Transposing multidimensional arrays in PHP

How would you flip 90 degrees (transpose) a multidimensional array in PHP? For example: // Start with this array $foo = array( 'a' =&…

php arrays higher-order-functions
Select/map each item of a Powershell array to a new array

I have an array of file names in Powershell, and I would like to prepend a path to each of …

powershell higher-order-functions array-map
array.groupBy in TypeScript

The basic array class has .map, .forEach, .filter, and .reduce, but .groupBy i noticably absent, preventing me from doing something …

arrays typescript grouping higher-order-functions
map for hashes in Perl

Is there a hash equivalent for map? my %new_hash = hash_map { new_key($a) => new_val($b) } %hash; …

perl hash higher-order-functions
Scala: How to convert tuple elements to lists

Suppose I have the following list of tuples: val tuples = listOfStrings.map(string => { val split = string.split(":") (split(0), split(1), …

scala tuples higher-order-functions