Skip to main content

Questions tagged [higher-order-functions]

Higher-order functions are functions which either take functions as arguments or return them as output (or both). They are a cornerstone of functional programming.

2 votes
4 answers
677 views

I am teaching a beginners course on JavaScript programming and web development. Passing a function as a value into another function is a very common thing in JS from the very beginning. As the ...
lishaak's user avatar
  • 467
-1 votes
1 answer
200 views

I'm interested in designing a high level function in Python, (I.E. a function that takes other functions as arguments) but I don't know of any good conventions for documenting such a function. For ...
Visipi's user avatar
  • 109
10 votes
5 answers
9k views

Let's say, for example, that I have a function makeFoo that makes another function foo: function makeFoo(string) { return () => string } const foo = makeFoo('bar'); I know that makeFoo is a ...
Splox's user avatar
  • 209
0 votes
3 answers
649 views

I am asking here something that is really haunting for years (for real !). I guess in a "perfect world", we would have programs made of data models and functions, and those functions manipulate data ...
ibi0tux's user avatar
  • 241
3 votes
3 answers
710 views

I'm trying to design a theoretical programming language and I'm facing a problem with high order functions. The language is strong-typed, so the way to define a standard function is like so : ...
ibi0tux's user avatar
  • 241
1 vote
1 answer
190 views

In Javascript, I have seen a code like: const getSomeMapper = (param1, param2, param3) (param4, param5, param6) => { // uses all these params and returns a promise } interface ...
Craftein's user avatar
  • 113
0 votes
2 answers
1k views

For clarification, let's review the following example: Consider that we have the following array of Ints: let array = [1, 2, 3, 4, 5] and we've been asked to generate a new array from array ...
Ahmad F's user avatar
  • 101
3 votes
2 answers
896 views

The Short (Original) Version How are function objects, sometimes called "functors" in C++ and other OO languages, where they make sense different from classes symptomatic of the poltergeist anti-...
Greg Kramida's user avatar
1 vote
2 answers
886 views

In order words, what's the advantage of writing this: Listing 1 var sortBy = function sortBy(p) { return function (a, b) { return a[p] > b[p]; }; }; Compared to this? Listing 2 var ...
alex's user avatar
  • 383
7 votes
2 answers
273 views

I've found that there isn't a concept similar to "arity-based subtyping" in many languages that I've programmed in, where higher-order functions could consume functions of lower arity than their ...
concat's user avatar
  • 517
3 votes
1 answer
291 views

Using the Tree representation(mentioned below), typedef enum {Running, Warning, Critical}Status; struct TreeNode; typedef struct List{ int childCount; struct treeNode **childList; }List; ...
overexchange's user avatar
  • 2,325
1 vote
2 answers
345 views

I have a function function name(src, dest, remove) { copy(src, dest); if (remove) { delete(src); } } What name should I give to that function? Alternatively higher order function ...
jcubic's user avatar
  • 143
1 vote
1 answer
141 views

I'm writing javascript object that wraps REST requests. For every operation on the server there is a method that accepts the parameters for the request and a callback that will receive the results. (...
Kasper van den Berg's user avatar
2 votes
6 answers
848 views

I'm new to compiled languages. I'm learning C. I'm used to coding in python. I was wondering if there was any equivalent, or replacement method in compiled langues for functions able to create a ...
loxaxs's user avatar
  • 147
4 votes
1 answer
1k views

I have been working for a few weeks on a new web project and I am realizing that all I am doing is basically calculations and transformations on data, and that most of my classes do not contain any ...
Carlos Rodriguez's user avatar

15 30 50 per page