Most voted "function" questions
The function (also called procedure, method, subprogram, or routine) is a portion of code intended to perform a single, specific task.
Learn more…1,309 questions
Sort by count of
-
4
votes3
answers408
viewsError listing items from a foreach() array
I have a array with the list of several Brazilian banks and need to take the name of the bank where the code according to what is in the user’s account, only when doing this search for code it…
-
4
votes2
answers18066
viewsAccess variable inside and outside a function
It is possible to access a variable inside a function outside of it? I would like to use a variable that was created in a function outside of it, but without returning by return of function. In PHP…
-
4
votes1
answer592
viewsLarge switch case in C
I am developing a system for the college and I would like to know what is the best option, in the sense of optimization of the code, of improving even. I have a switch Menu case, where I have 88…
-
4
votes1
answer352
viewsHow to return all data from an SQL query outside of Function?
I have a function which has the objective of showing all the results of an SQL query to the database and need to assemble a view with the data of this query. To function is the following: function…
-
4
votes1
answer78
viewsSingle ring value
I’ve seen several posts on the subject but it’s not exactly what I was looking for. A while ago when I was in internship, I was told to keep some records with a unique id on each one, and they told…
-
4
votes3
answers655
viewsHow to use a dictionary value to call a specific Python function?
I’m trying to use a dictionary to identify each function to a value, and call them over the program. My code is below (example): #!/usr/bin/env python menuOpt = { 1 : "valor", } #Main if __name__ ==…
-
4
votes1
answer1523
viewsCorrect use of free() in function?
How to use function free() when it is used within a function, in that function Gero a dynamic vector and the function itself will be the return, example: int* copia(int *vet, int tam) { int i,…
-
4
votes2
answers293
viewsChange System Logo
I am creating in a system that I am developing for our client, a function where it allows the same to upload the logo and cut the same, then when it saves I am trying to load the image that was…
-
4
votes1
answer7212
viewsPass Array as a function parameter
Make a program in C that reads a value x, dynamically create a vector of x elements and pass this vector to a function that will read the elements of this vector. Then, in the main program, the…
-
4
votes1
answer270
viewsA: Insert date difference in a time difference function
I found a function made by J.Ahumada and found it super interesting, everything to do with my work. The function is to separate photographic records of a species into a given sample unit(ua) from a…
-
4
votes2
answers1267
viewsVariable declaration before the main() function and after the main() function in C
What is the difference between declaring any variable (in this case number) before function main()? int number = 0; int main() { printf(" The number is %d\n", number); return (0); } and after it.…
-
4
votes1
answer1052
viewsParameters of the scanf function
When studying the function scanf with a little more depth I arose a doubt about the arguments I put before the % when reading a string, ie scanf("argumentos...%s",minhastring), in the following…
-
4
votes1
answer192
viewsParallel Processing Routine C#
I would like to start a data processing method whenever I receive a String with START content through the Transceiver event.Receivelineeventhandler(); but this method will have a processing time as…
-
4
votes1
answer202
viewsAs per comments on user defined function in Excel/VB
I would like to know how to by that help in user-defined functions in Excel. Not how you create the user-defined function, and yes as it adds instructions as user must manipulate it.…
-
4
votes4
answers100
viewsfunction_exists fatal error
Hello, I need help to solve this problem. I have the following code snippet (put the line number to facilitate): **186** if ( function_exists( self::$function_val() ) === TRUE ){ **187**…
-
4
votes3
answers163
views"Carry" variables between functions, appears strange character in place?
In function main when I print a char, it appears a strange code like a hexa: But when I print the same char in another function it appears normal. char tempA[100] = "1111"; int main () {…
-
4
votes1
answer239
viewsHow do I get rid of these warnings
I’m doing a program that hunts a word from a matrix. For this I made 8 functions that sweep in all regions, as I need to return in the output the coordinates of the first and last letter. For…
-
4
votes4
answers3012
viewsHow to convert scientific notation to full number string
What php function should I use to do this type of conversion? Convert: 1.3388383658903E+18 to: 1338838365890273563 I tried that, but it didn’t work: echo sprintf(sprintf('%%.%df', 0),…
-
4
votes1
answer279
viewsBuild Accumulated Density Probability using R
I have this two-column date frame (Y and X) With the package quantreg I can estimate the amounts of Y given x. Done this I’m not managing to build the CUMULATIVE Y conditional density function.…
-
4
votes2
answers4695
viewsHow to change the value of a variable by function in Python?
How can I change the value of a variable through a function? Here’s an example of what I’d like to do: def func(t): t = 2 + 3 t = 7 func(t) print(t) The output of the print(t) function returns me…
-
4
votes2
answers54475
viewsPlace Javascript function inside onclick
So it’s kind of a silly question, but I really need... has how I put a Javascript function inside a buttom in this example below it calls the function loadDoc(). more I would like to put the…
-
4
votes3
answers137
viewsFunction to double salaries in n installments?
I’m having trouble creating a function to duplicate pay, my scenario is this, I want to move to function 3 variables, being the valueTotal, qtyParcelas and firstVencing and if there is more than one…
-
4
votes1
answer544
viewsExport array within a table?
I need to export data from an array inside an html table, the function is working but I don’t know how to export while inside a table, I made an analogy with the code below. function…
-
4
votes2
answers85
viewshelp here div and html functions
I have this code, when I pass the mouse over the div it moves, but I wanted it to happen when I hit the button: <head> <style> .square{width:100px ;height:100px ;background:red…
-
4
votes1
answer343
viewsGettype() Laravel
I’m trying to get the type of the columns of the tables of my BD, and how to use PHP with the Laravel I tried to use the GetType to pick up the guys and show on view. But the code is only returning…
-
4
votes1
answer1892
viewsHow to call one function inside another in Java for Android?
Every letter the user types in EditText, invokes the function TextWatcher that leads to a Text-to-speech. So if it writes 'c', the app returns a line saying 'c'. if it then enters 'a', returns 'a'.…
-
4
votes1
answer92
viewsFunctions R - Strange Character
I created a function in the R and detected a strange character appearing on the return of the function. Can you explain to me? Here is the function: funcao_categorica <- function(xx){ rr <-…
-
4
votes1
answer195
viewsDifference between exporting a function and an IIFE in Javascript
Is there any difference between: module.exports = (function() { // Code. })(); And: module.exports = function() { // Code. }; Taking into account the context of exporting and importing modules?…
-
4
votes1
answer101
viewsPass by reference printing garbage in the vector
Guys, I made a simple code, but I have a problem. I made a function "increase" to increase the size of a vector; the function receives the vector and passes the values of that vector to an auxiliary…
-
4
votes1
answer97
viewsHow much each function "costs" to the server
My question is about function is_dir to find out if there is a directory. How much does it cost for the application to use this function? How to measure the use of this or another function in PHP?…
-
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")…
-
4
votes3
answers229
viewsFunction within Jquery what is the execution order?
I have a function in jquery that has a while that writes data to the database, and after this while it prints on console that the data was saved, the function is like this: function gravaDados(){…
-
4
votes1
answer10576
viewsSplit text in excel
I have to divide the "Full Name" cells of my table into two. Therefore, I used two functions: "Left" to take the person’s Name and "Right" to take the last name. In which, everything up to the first…
-
4
votes1
answer47
viewsWhat is the name of a non-retail recursion?
In tail recursion, the recursive call is the last thing the function does, and can be optimized. And when is it not tail? What is the name? "Common"? "Body"? There must be a specific name for it!…
-
4
votes3
answers1583
viewsfunction in R that also returns the execution time itself
I know there is Rprof(), but it seems to me rather inaccurate compared to microbenchmark(). However, if I want to use the microbenchmark() I have to call the function 2 times, once to have her…
-
4
votes1
answer461
viewsUpdate cart status without leaving the page | Woocommerce 3.4+
<?php global $woocommerce; if ( sizeof( WC()->cart->get_cart() ) < 1 ) { ?> <div style="width: 25%;" class="footer-section <?php echo esc_html($woo);?>"> <a…
-
4
votes2
answers189
viewsSum function with a large value returns a wrong result
Why is my summation function returning to me 633223344234234200000 and not 633223344234234234235? function plus(n) { return n+1; } console.log(plus(633223344234234234234))…
-
4
votes2
answers106
viewsFunction with a pointer?
Enunciation: A student’s grade is calculated from three grades awarded from 0 to 10 respectively to laboratory, a bimonthly evaluation and a final examination. The average three notes mentioned…
-
4
votes2
answers151
viewsWhy does changing a variable in a function not reflect in the passed variable itself?
let a = 2; let change = (val) => { val = 3; } change(a); console.log(a); I hoped the value of a was 3, but actually it is 2. Why?…
-
4
votes1
answer220
viewsHow to add 1 to the number using the "for" command when the number N is a function parameter?
Being n the value of 5, adding up 1 + 2 + 3 + 4 + 5, resulting in the return. I tried to do it like this, but it didn’t work: function (n){ for ( var i = 0; i < n.length; i++ ){ total += n[i]; }…
-
4
votes2
answers76
viewsFind() function of the set library does not return whether or not it found
I’m writing a little program for a college exercise and I’m having second thoughts about find(). I must enter two integer numbers, check if the first number exists within the set previously defined.…
-
4
votes1
answer179
viewsWhat are the main differences between Arrow Function and Closures (anonymous functions) in PHP?
In version 7.4 of PHP, it was implemented Arrow Functions. Example: $double = fn($x) => $x * 2; var_dump($double(4)); // int(8) Which could be done as follows in previous versions: $double =…
-
4
votes1
answer232
viewsfread(); problem in implementation
I have a simple problem. I can use the function fread normally to work with audio processing in C. In case I have 2 codes. The first reads a file . WAV (with fread) and saved in a .CSV. file This…
-
4
votes2
answers164
viewsWhat would this . f be in Javascript?
Taking a look at a tutorial on Javascript I came across the following code snippet: let user = { name: "John" }; function sayHi() { console.log(`Hello ${this.name}`); } user.f = sayHi; // dúvida…
-
4
votes1
answer217
viewsHow to set default in parameters when specifying the type of the object?
When defining functions, I usually use the feature of specifying the type of object that can be used as argument and which object the function should return. See example below: def…
-
4
votes1
answer115
viewsCreating a dictionary with void functions
I am for fun to develop a TCP server in C# that performs functions depending on the message that the connected client sends you, for now, I only managed to do what I want with functions that return…
-
4
votes2
answers186
viewsDoubt about Number.isInteger() in JS. Number is an object or function?
Number would be a function or object? My teacher said that everything in Javascript can be seen as a function (even objects) and it confused me a little. He told me that Number would be an…
-
4
votes1
answer58
viewsWhy does a function accept a reference instead of returning a value?
Consider the code snippet below: int num; printf("Enter a number: "); scanf("%d", &num); I understand that by passing &num to the second argument of scanf(), step the variable reference num,…
-
4
votes2
answers48
viewsHow to pass Corner Blob effect to right side of the screen?
I would like to reverse the effect demonstrated by starting from the right side of the screen and expanding to the left side, however, I did not achieve this. Someone could give me a light? const…
-
4
votes1
answer39
viewsShould reducing functions be created outside or inside my React component?
Looking at the documentation of hook useReducer, I checked that the reducing function is created out of of the component: const initialState = {count: 0}; function reducer(state, action) { switch…