Questions tagged [anonymous-function]
Anonymous functions use a block of code as a value, defining it as an inline function without a name.
anonymous-function
2,136
questions
0
votes
2
answers
71
views
Where are anonymous callback functions to setTimeout stored?
I have a simple program that looks like this:
console.log("Start of the program execution!");
setTimeout(() => {
console.log("I ran after a second!");
}, 1000);
console....
0
votes
1
answer
27
views
imap-ing over multiple glmers in R: Anonymous functions
I have this function:
mweFitModelsGLMER <- function(longData,
strModelName = "ID Rand Model",
strFormula = "phMeta_Toxicity ~ ...
0
votes
1
answer
47
views
Can I check if ReflectionType is instance of another type?
I want to check if a callable's return type is an instance of another type. For example, let's say I a have:
A class Pigeon which extends Animal.
A function addSupplier() which takes a callable ...
0
votes
1
answer
35
views
Capture the for-loop iteration value to create anonymous function for dynamically generated downloadHandler
I'm developing an R Shiny App building a list of graph and I want each data to be downloadable by a click on a button below each graph.
My problem is that the anonymous function created to handle the ...
0
votes
0
answers
33
views
In some cases, "this" in the function passed as an argument to the higher order function is Window or undefined. Please tell me the difference [duplicate]
class Foo {
m(f) {
f();
}
}
let foo = new Foo();
foo.m(function () {
console.log(this);
// Window
});
class Foo {
m(f) {
f();
}
}
class Boo {
m2() {
let foo = new ...
0
votes
0
answers
20
views
Assigning a TProc inside a non-generic inline method leads to compiler error. Why?
When trying to assign procedure begin end to a TProc in the code below,
I get a compiler error:
E2441 Inline function declared in interface section must not use local symbol '.TMyClass.DoesNotCompile$...
0
votes
0
answers
18
views
What is the difference between `function () {}` and `() => {}` in JavaScript?
I am trying to add a method to the Person constructor function but keep getting an output of "Hello undefined"
function Person(name, age) {
this.name = name;
this.age = ...
2
votes
2
answers
108
views
PHP chaining callback functions
I've encountered this code, but I can't understand its logic. Could someone explain why the output is the way it is?
<?php
$functions = [
function($next) {
echo 'A' ....
2
votes
3
answers
113
views
Is it necessary to use lambda symbol in Common Lisp?
I've been reading Paul Graham's ANSI Common Lisp recently, where he mentions
In Common Lisp, you can express functions as lists, but they are represented internally as distinct function objects. So ...
0
votes
0
answers
26
views
Why is my nested function not called from my anonymous function? [duplicate]
I tried accomplishing a small task in PHP 7.4 (a language I never use) and decided to use a nested utility function isReverseScored, to be called inside an "arrow function", like so:
// ...
4
votes
0
answers
160
views
Why can't C# infer the type of anonymous delegates/functions in some cases?
I'm using C# 12.
When assigning a function to an implicitly-typed (var) variable, C# can infer the type successfully, such as in this example:
// Scenario A
var func = () => "Hello World";...
1
vote
1
answer
67
views
Attach an anonymous function to an "onclick" attribute of a link
On various pages of a website I generate via JavaScript different click handlers attached to links in the innerHTML of an specific page element. I do it with a uitilty function like this:
function ...
5
votes
1
answer
168
views
What is the difference between an anonymous function and a function handle in MATLAB?
I hear these two terms, anonymous function and function handle being used to refer to something like f = @(x) x.^2 in MATLAB. But then I've also heard that these terms mean different things. How do ...
1
vote
0
answers
38
views
Simplifying a function handle using another function handle with partially given variable in Matlab
With the following code in Matlab"
f = @(a,x) a*x+3;
g = @(x) f(4,x)
I get g as a function handle of the function handle f.
g = @(x)f(4,x)
However, I want to get g as a function handle without ...
0
votes
1
answer
60
views
Return data from async anonymous function that is an argument to a non-anonymous function
I'm attempting to return the contents argument of an async anonymous function. The contents argument is populated within the anonymous functions block but on return it is undefined.
I've attempted ...