Most voted "anonymous-function" questions
Anonymous function is a function that does not have a defined name, exists in languages that allow assigning reference of functions to variables and properties.
Learn more…29 questions
Sort by count of
-
43
votes5
answers22471
viewsHow do anonymous functions work?
I know they are functions that do not have the specified name, but what is the purpose? Is it possible to recur with anonymous functions? Ex: Fibonacci sequence. (function(x, y) { alert(x + y);…
-
17
votes1
answer23130
viewsHow to pass a function as parameter in C?
I wanted to know how the function passed by parameter as it happens in pthread_create (thread,atributo,rotina,argumento);. On the field rotina a function is placed in void*.…
-
15
votes1
answer704
viewsWhat is and what is an anonymous function in R?
What is an anonymous function? And why can it be called função lambda? What is the usefulness of an anonymous function in language R? Where it can be applied (for example, it can be applied in…
-
10
votes3
answers168
viewsWhy is it necessary to create a function to execute certain methods?
.onclick = function() {myFunction()}; Why the example below does not work? .onclick = myFunction() It runs without me having clicked! <script> document.getElementById("demo").onclick =…
-
7
votes2
answers1844
viewsHow to declare an anonymous function in Python?
How do I declare and how an anonymous function of Python?
-
7
votes1
answer702
viewsUse a void function as a parameter of another
Let’s assume that I need one function to perform to a certain point, call another, do some action, call another function, do one more action and finish executing. Whereas the called functions…
-
5
votes2
answers390
viewsWhy can’t an anonymous method be assigned to a var or Dynamic?
The following code: var mostra = delegate(string x) { Console.WriteLine(x); }; mostra("teste"); The . Net should not identify the var as a Action<string>? And the same for dynamic?…
-
5
votes2
answers90
viewsWhat are these complex members within a struct?
I have a question in a struct on the last lines with uchar and void which is quite different from what I know. Why many programmers use underline in the names of structs, variables etc... struct…
-
5
votes2
answers172
viewsWhy don’t I need to declare the parameter in the function?
In the React documentation he brings an example of form, when the input receives some property value onChange is called with the function handleSubmit(event) in that way onChange={this.handleChange}…
-
4
votes2
answers872
viewsWhat are anonymous methods and what is their main purpose?
I know they’re used to working together with delegates, but the sources I found were a little confused in my opinion.
-
4
votes3
answers702
viewsFunction that takes another function as a parameter in C#
In the language Lua has how to create a function that takes as argument another function, for example : exemplo = function(outrafunction) outrafunction() end exemplo(function print("alguma coisa")…
-
3
votes1
answer181
viewsWhat are the variables/functions Anonimas and closures for? And what are they for? How to use?
I think most of the question has already been asked in the title. More specifically, I wanted real examples of using these techniques and the relationship between them. Note: I read other related…
-
3
votes1
answer231
viewsHow to create an anonymous (Closure) recursive function?
In php, we can create recursive functions as follows. function quack($quack = 1) { if ($quacks >= 1) { echo "Quack"; $quack--; quack($quacks); } } Or, in case of avoiding problem with "renaming"…
-
3
votes1
answer565
viewsIs it possible to call an anonymous function?
I wonder if it is possible to call an anonymous function outside her scope. When I call the function, this error occurs: Uncaught TypeError: consomeCsr is not a function Example: consomeCsr =…
-
3
votes2
answers170
viewsWhat is the difference between these uses of the setTimeout() function?
What’s the difference between using the setTimeout() thus setTimeout(()=>this.logicaRotacao(), 3000) and so? setTimeout(this.logicaRotacao(), 3000)…
-
3
votes1
answer567
viewsParameterize functions to receive functions
What are the advantages of parameterizing Dart functions? void main() { metodoSemFuncao(); metodoComFuncao(funcao); } void metodoSemFuncao(){ funcao(); } void metodoComFuncao(Function func){ func();…
-
3
votes2
answers116
viewsIs there anything in ADVPL equivalent to Java lambda function?
I am maintaining an ADVPL project. In it, I have some source files. Among these sources, I have an information miner in the GEO1 file and a communicator of the information mined in the GEO3 file. In…
-
2
votes1
answer3027
viewsAnonymous function returns: syntax error, Unexpected T_FUNCTION
When trying to use this function: <?php echo preg_replace_callback('~-([a-z])~', function ($match) { return strtoupper($match[1]); }, 'hello-world'); PHP returns this error: Parse error: syntax…
-
2
votes2
answers79
viewsPHP - online lambda functions
Dear, I have a system where the user (with development permission) can program some online routines, to be executed within the system, without the need to create file and call via require / include.…
-
1
votes1
answer324
viewsHow to pass a function pointer by parameter?
I need it passed through argv[], in the main function, the name of a function that will be called by the same. I can’t make comparisons of strings, then I must make the call with variables. Here is…
-
1
votes1
answer418
viewsFunction int(*Cmp)(void*,void*)
I know it compares pointers and returns an integer that determines whether one is smaller than another, in order. But, when I will use it in main(), is giving some error. Can help me?…
-
1
votes1
answer171
viewsHow do callbacks and anonymous functions work in PHP?
Good afternoon, How an anonymous PHP function works? How does the callback in PHP? How to work the two together? (anonymous and callback) I studied a little Javascript and found it very different in…
-
1
votes1
answer50
viewsWhat is the behavior of two anonymous functions in an object?
Explain: StarGate = {}; StarGate.c = {}; StarGate.c.m = function(t, e){ return "teste1"; },function(g){ console.log('teste2'); }(StarGate.c.m.prototype); I have doubts because, what would be the…
-
0
votes1
answer400
viewsHow to use Js events without html
How do I make it spin ? <html> <head> <script language="javascript"> function teste(){ alert("oi"); } document.getElementById("as").onclick = function(){ teste(); } </script>…
-
0
votes1
answer55
viewsError in anonymity function does not allow compiling
I am studying a PHP OO book. There is an example of anonymous function, but is giving error: # FUNÇÂO ANONIMA $remove_acento = function($str) { $a = array( 'à', 'á', 'â', 'ã', 'ä', 'ç', 'è', 'é',…
-
0
votes0
answers87
viewsI cannot add element to DOM through an anonymous function in JS
I created a table via javascript by manipulating elements of an array, which is all right, but I can only add the table in the DOM by a common function or an anonymous Jquery function, but when the…
-
0
votes1
answer269
viewsHow do functions that receive callbacks be executed in a specific order?
Let’s analyze the code snippet below, in Javascript: function rand(min = 1000, max = 4000){ return Math.floor(Math.random() * (max - min) + min) } function f1(callback){ setTimeout(function(){…
-
-2
votes1
answer39
viewsHow can I use more than one function in the same Thread?(python)
I already tried that but it says that the is not defined: import threading as te import time b=[] def c(): global a a=0 while b==[]: time.sleep(0.001) a+=0.001 def i(): b.append(input('enter'))…
-
-3
votes1
answer283
viewsHow to determine the order of executing callbacks functions without resorting to anonymous functions and how does the stack of executing functions in JS work?
Analyzing the code below: function rand(min = 1000, max = 3000){ return Math.floor(Math.random() * (max - min) + min) } function f1(callback){ setTimeout(function(){ console.log('f1') if(callback)…