Anonymous functions use a block of code as a value, defining it as an inline function without a name.
Questions tagged [anonymous-function]
2121 questions
0
votes
1 answer
Anonymous Function Showing End Function Warning
I am trying out FluentValidation, and I'm converting a C# RuleSet example to VB.NET.
Question: Why is VS 2019 putting the green squiggly line under End Function, stating the function doesn't return a value on all code paths. Should I be doing…

HardCode
- 6,497
- 4
- 31
- 54
0
votes
1 answer
Prefer variables inside or outside anonymous function
Lets say I have an anonymous function that needs a few variables to keep track of its state. The function works the same with the variables inside or outside the anonymous function. Are there any performance or other considerations when deciding…

Ava
- 2,038
- 3
- 23
- 45
0
votes
2 answers
Extracting a method from a Linq query
I have the following static method, which returns all possible combinations of triples from an IEnumerable, that are pythagorean. eg: for int[] array = {1, 2, 3, 4, 5}, it will return new[]{{3, 4, 5}, {4, 3, 5}}.
public static…

Balada Rock
- 33
- 7
0
votes
2 answers
R group by one column and apply custom function to another column
Say I have a data frame like this:
x <- data.frame(x = c(rep("A", 5), rep("B", 5), rep("C", 5)), Data = rep(1:5, 3))
How do I apply this function to the second (numerical) column by each group A, B and C?:
Percent <-…

Luther_Blissett
- 327
- 1
- 6
- 16
0
votes
2 answers
This expression has type unit but an expression was expected of type unit -> bool
my perpose (I wrote this explain after question and best answer) :
I wanted to call each different function case token of char with read string. So, just I wanted to do do is loop function that call each different function drives the char.
I'm…

y.s
- 15
- 1
- 6
0
votes
1 answer
Which React Hooks can be defined anonymously?
In order to avoid unnecessary renders, for brevity can Memoize hooks be defined anonymously?:
Would button still re-render as intended; Only when deps…

ecoe
- 4,994
- 7
- 54
- 72
0
votes
1 answer
Summation of N function handles in MATLAB efficiently
I would like to calculate the following function efficiently, and therefore preferably with a function handle.
In the given equation only "s" is the variable. The rest are some known constants but they are changing inside the loop. I would like to…

Seyhmus Güngören
- 139
- 5
0
votes
2 answers
How to create a class with annonymous functions in Angular8
I'm developing an Angular 8 app and need to use a library for displaying 3D models (JS + WASM). For interaction between my Tree Table and 3D model, I need to register an observer in this library.
The given codesample for registering the observer…

Benjamin Steiner
- 83
- 5
0
votes
1 answer
Is there a way to access the input object after it was piped?
Is there a way to pipe a whole object through a pipeline and process mentioned Object in one step? Put simply the $PSItem Variable on the other side of my pipeline should have the same value as the whole object which was put through the pipe.
I've…

MichaelS
- 3
- 1
0
votes
2 answers
Pass data back to anonymous function via callback?
I've been researching callback functions in the JavaScript language lately and during my testing I've encountered an issue that I didn't foresee, but once I encountered it, I understood what the issue was most likely to be.
I've written two methods…

Hazel へいぜる
- 2,751
- 1
- 12
- 44
0
votes
1 answer
Can Matlab integral2 deal with a non-anonymous function?
I have a user-defined function
function[Rout2] = SSP2(a1,a2,b1,b2,pB)
if a1/b1>a2/b2
if pB<=a1-b1*a2/b2
Rout2 = (a1-pB)/b1;
else
if pB<=a1+a2
Rout2 = (a1+a2-pB)/(b1+b2);
else
Rout2 = 0;
end
…

KevinKim
- 1,382
- 3
- 18
- 34
0
votes
1 answer
Using an object passed as a parameter to a function in an inner anonymous function C#
Just for testing purposes, I've created a class MyData that holds an int property called Id.
public class MyData
{
public int Id { get; set; }
}
Then, in an Main function of an App Console, I initialize two instances of this class.
MyData…

user2896152
- 762
- 1
- 9
- 32
0
votes
1 answer
Call an anonymous function within a custom function MATLAB
I want to call an anonymous function in a custom MATLAB function. From the script that calls the custom function, I want to minimize the custom MATLAB function. I am having a problem with the anonymous function not being passed correctly to the…

Physics314
- 341
- 1
- 2
- 9
0
votes
1 answer
$emit does not work from an anonymous function
In the mounted hook I have the following anonymous function:
window.onkeydown = function(evt) {
evt = evt || window.event;
var isEscape = false;
if ("key" in evt) {
isEscape = evt.key === "Escape" || evt.key === "Esc";
} else {
…

sanders
- 10,794
- 27
- 85
- 127
0
votes
1 answer
How to case match on a function with optional parameters
I want to be able to have a method with an optional parameter. When that optional parameter is present, it will call a specific DB query that returns records filtered with the optional parameter. If that optional parameter isn't present, I want it…

Chris
- 785
- 10
- 24