First-class functions can be assigned to variables, passed to other functions as arguments, or returned from other functions. The ability to return a function enables deferred execution. Functions that accept other functions as arguments are called higher-order functions.
Questions tagged [first-class-functions]
132 questions
0
votes
2 answers
Actionscript: How exactly does ExternalInterface.addCallback() work?
I'm pretty new to ActionScript, but not new to either object oriented or procedural languages in general. ActionScript's particular combination of features from both categories, however, confuses me.
Specifically, I'm confused about the mechanism of…

Kevin
- 2,617
- 29
- 35
0
votes
2 answers
Optimizing and implementing lengthy arrays of functions in Javascript
I'm currently implementing an emulator in Javascript, the memory model of the emulated platform is rather complex, so I'm having my reads and writes go via an array of functions, for example:
var MRead = [];
ReadBiosSpace = function(addr) { return…

Fascia
- 732
- 6
- 17
-1
votes
1 answer
How to change a function based on unknown number of arguments in javascript
Is there any way to add to or manipulate expressions in a returned function?
This is an example for a single argument:
function trackByProp(prop) {
return function (value) {
return value[prop];
};
}
The aim is to extend this function to…

Nicholas Foden
- 156
- 3
- 12
-1
votes
2 answers
Why i only need to provide "console.log" to my catch promise method to log error?
I have a simple promise, but I wonder why in my catch method I only need to pass "console.log" and it will automatically log that error if it happens?
Does it have something to do with the fact that catch automatically gives us an error object or…

arthasnp98
- 13
- 1
- 6
-1
votes
2 answers
Go, first class functions, and best practices
For the past few days, I've been at a road block with regards to the best way to approach the issue of first class functions (assigning a callable to some variable), and the best practices in terms of efficiency.
Let's say I am programming a Yugioh…

adespotakis
- 61
- 5
-1
votes
1 answer
Different behavior when assigning a function to a variable or a table
I have got a different behavior between a table and a simple variable assignation with a function. This difference does not exist when assigning a number for instance.
-- works fine
arrNum={1234}
Num=arrNum[1] -- Num=1234
arrNum[2]=arrNum[1] --…

user1771398
- 475
- 6
- 18
-1
votes
2 answers
Parameters of a function variable
After distilling the answers to How are parameters handled when passing functions in Javascript? I ended up with one question I need to clarify.
In the sample below:
function plus2(x) { return x+2; }
var Q = function(y) { return plus2(y);…

Old Geezer
- 14,854
- 31
- 111
- 198
-1
votes
1 answer
Explain the term 'First-class functions' in relation to Javascript
Can someone explain this term for me and describe a typical programming situation where first-class functions are used?
Thanks

hiimmrwood
- 5
- 2
-1
votes
1 answer
Lazy initialization of object passed as argument
Let's say I have a method that takes a very long time to create an object,
public class Foo implements Serializable {
public static Foo create(...){
/* (takes a long time) */
}
}
I also have a helper class that serializes and…

jedwards
- 29,432
- 3
- 65
- 92
-2
votes
1 answer
Why First Class Function Notation is not working in the class methods?
Hello Hope you guys are doing well.
I have a class which has several methods and I have a runner which randomly executes a function out of the several class methods. I have tried using First Class Function methodology in runner function but runner…

Malik Abdulaziz
- 57
- 6
-2
votes
1 answer
Python 3 parameter closed upon by inner/nested method falls out of scope and triggers UnboundLocalError
Edit: Why are people downvoting this post? Are Python developers really this inept? It's a legitimate question, not one that's been answered in other places. I searched for a solution. I'm not an idiot. One parameter has a value and the other one is…

devinbost
- 4,658
- 2
- 44
- 57
-2
votes
1 answer
Javascript First Class Functions
While reading about Javascript First Class Functions here at SO, I came across this link:
What is meant by 'first class object'?
wherein I found this interesting example:
var men = function (objectOfAdmiration) {
return…

Mani Malhotra
- 97
- 1
- 3
- 12