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
-
3
votes2
answers830
viewsReturn and pass structure through a function in C
Good evening, I am with a work of completion of discipline in which I have to register N employees, in my code I put 5 to get faster the tests. This information would be saved in a structure and how…
-
3
votes1
answer154
viewsHow to leave this function javascript
I have this function below and I would like to leave it generic, because the values of innermap, -125,127 and 3 will vary. Instead of creating multiple functions: centralizar(); centralizar1();…
-
3
votes1
answer751
viewsReturn of Struct in C
Hello, I’m trying to return a struct from a function when it’s called on main. I did the whole function and set in the end two elements which are calculated in function: int mult[100]; char**…
-
3
votes1
answer5770
viewsWhat is the logic behind the trunc function?
What does the trunc to be sure and what other uses may have taking this example?…
-
3
votes1
answer278
viewsDecode vs Case Query
We have two ways to work with condition within consultations in Oracle SQL, are they the Case and the Decode, the two have the same function. Allow dynamically and practice how to get a return from…
-
3
votes1
answer2858
viewsOptional parameter in function
I was trying to create a square root function: def root(n, ind): if ind == None: ind = 2 ind2 = 1 / ind print(n ** ind2) I want the ind not be mandatory. I thought if I didn’t, the value would turn…
-
3
votes2
answers2577
viewsFind amount of times a character appears in a word using recursiveness
Develop an algorithm that reads a word (string) a character and return the number of times this character appears in the word. The algorithm must be recursive. Examples of Input and Output: Entree:…
-
3
votes1
answer4316
viewsError: non-numerical argument for binary operator
I’m working on the following code: temperatura<-function(t){6/pi*atan(40*t-740)+7}#temperatura em função do tempo…
-
3
votes2
answers1038
viewsHow to omit parameters in the actual parameter passage?
I have a C++ function called minhaFuncao() thus declared: minhaFuncao(int x, int y, float a); and thus implemented: minhaFuncao(int x, int y, float a=0){ ... } What I’m trying to say is, when you…
-
3
votes2
answers10609
viewsHow to get the lowest value in a list?
I’m stuck in this program, I can’t create a function in Python. The exercise is as follows: Write a function called buscarMenor() that takes a list of integers and returns the smallest of the…
-
3
votes0
answers848
viewsCalculate the shortest possible distance
In an exercise, I need to print all possible paths between cities, and cities are represented by coordinates x and y and that the last city is the city of departure. Remembering that should be found…
-
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
votes3
answers400
viewsHow to return 2 vectors of different types in C++
I perform a calculation and my result is saved in a vector<int> and a vector<string> How do I make my function return these two parameters in mine main()? int cracking(string chemform) {…
-
3
votes1
answer239
viewsHow to create structure vector within function
Good morning! I got recovery again in the matter of algorithms, what got me most was structure and passing parameters. I decided to create an activity to train for recovery Monday. Following the…
-
3
votes1
answer164
viewsAbout the behavior of userland functions and internal functions in PHP
There is a proposal to unify the behavior of userland and internal functions in the PHP 8. That currently in particular, when internal functions fail to parse argument types correctly, they fail to…
-
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
votes1
answer67
viewsDoubt: Function of generators
Write your own generator function which works as the internal enumerate function. Using the function thus: lessons = ["Why Python Programming", "Data Types and Operators", "Control Flow",…
-
3
votes1
answer1363
viewsPass data from a struct within the function
I’m doing a college job where I have a separate function that gets two values (WEIGHT and HEIGHT) and returns the BMI. I have tbm a struct called STUDENT where is stored weight and height and a…
-
3
votes4
answers382
viewsHow to call function in JS only once
Well, I have the following problem: I’m building a chat page, I’m already getting good messages, only when entering this chat page I wanted to automatically descend to the bottom of the page, in…
-
3
votes1
answer63
viewsWhat is the parameter passed in Sort()
Doing an exercises I came across the following parameter passage in sort(): let notas = [7,6,10] notas.sort((a,b) => a < b ? 1 : -1) console.log(notas) I could not understand, since I have…
-
3
votes1
answer776
viewsWhen and where to use the terms: time complexity, space complexity?
I’m using the book Data Structures: Algorithms, Complexity Analysis and Implementations in JAVA and C/C++ as it helps with practical implementation examples. In chapter 1 there is the following…
-
3
votes2
answers2190
viewsHow to pass a matrix as a reference to a function?
I’m trying to pass as a parameter a matrix for a function as a reference, and in this function do operations in this matrix but I’m not getting. I don’t want you to use define or const int for the…
-
3
votes3
answers171
viewsDoes the function not return the minimum value?
Make a Python function call min_max(t), which receives a list of numbers, and returns another list containing respectively the lowest and highest value of the original list. Follow the code so far:…
-
3
votes1
answer172
viewsWhat is the breakpoint function for
I’m digging myself in python, and as a good curious beginner I am researching the functions already present in the python without the use of any library, when I come across the function…
-
3
votes2
answers226
viewsHTML5 Dynamic Drawer
Good morning! I rode several blocks with a div that through Javascript, it interacts as if it were opening a drawer (block) with a click and closing it with two clicks through a function. But when…
-
3
votes3
answers85
viewsAre the variables of a function automatically deleted after its termination?
I am developing a function that has variables that carry a lot of data and as these variables are used only within this function it does not make sense that they continue occupying space in memory,…
-
3
votes2
answers1851
viewsHow to assign a function to a button in Django Python
I am doing a Jango course and I would like to know if it is possible to assign a function to a button. For example: <form> <label for="word">Digite uma palavra:</label> <input…
-
3
votes3
answers243
viewsUse of functions in Python
I know that it is possible to create functions in the Python to perform certain tasks that normally need to be performed several times within an application. Ex: Paint shop program that calculates…
-
3
votes3
answers337
viewsError calling function that returns string in C
I made a program that asks for name and surname to be concatenated through a function: #include <stdio.h> #include <string.h> int main(void){ //Declarando Funçãoo char retornaNome(char…
-
3
votes1
answer40
viewsHow to reference columns in a R function?
My question is how to announce a column in the Arglist of a Function.Example: I want to do this library(data.table) a<-mtcars data.table::setDT(a) a[,.( disp2 = sum(disp), cyl2 = mean(cyl) ), by…
-
3
votes3
answers993
viewsRemove "disabled" with Javascript
Good evening. I wanted to remove the disabled attribute from a tag when a certain condition is met, but I couldn’t find any idea how to do that. Below the HTML: Escreva aqui: <input type="text"…
-
3
votes1
answer85
viewsHow to access, within a function, a global variable that has the same identifier as the variable within the function?
Let’s assume I have the following Javascript code: let variavel = 22 function funcao(){ let variavel = 333 console.log(variavel) } funcao() //333 We realized that, since the variable declared within…
-
3
votes3
answers757
viewsIs there a command or function in Javascript that controls the screen update before the loop ends?
Just one example: <script> for (var i=0;i<10;i++) { //Inicia loop for para contar de 0 até 9 var t=0; // inicia variável t com valor 0 while(t<1000000) { //inicia loop enquanto t for…
-
3
votes1
answer78
viewsHow do I distribute the content of a column to other columns in R?
I’m trying to distribute the contents of one column in another 3 columns. I have the following Data Frame: library(tidyr) df<-data.frame(Coluna= c('2237-5953', '(RE) PENSANDO DIREITO', 'B4',…
-
3
votes2
answers97
viewsHow to filter rows where columns meet consecutive conditions in Python?
I’m trying to filter lines in which the columns comply with conditions consecutively. That is, if the row has columns with the conditions of after an L/I, the next column has a A/S, then return the…
-
3
votes1
answer34
viewsTransform 3 similar functions into one
In my project, I have very similar functions, with the same intention, however, as it is a DOM class exchange function (classList.replace), I ended up making a very repetitive code, and I’d like to…
-
3
votes1
answer60
viewsHow can a value be invoked (as a function) at the same time as it contains properties (as an object) in Javascript?
I was left with a question concerning the structure of the Express. How Express can be invoked, as in express(), but can also have in its structure access to the Router property, for example? I…
javascript node.js function characteristic-language objectsasked 3 years, 8 months ago Otavio Fagundes 978 -
3
votes3
answers81
viewsIs it possible to use functions in an arbitrary order in C++?
Apparently, the order in which functions are written matters in C++. Example, this code compiles: #include <iostream> using namespace std; int add_number(int x, int y){ return x+y; } int…
-
3
votes2
answers127
viewsHow to detect Start Codon and Stop Codon in a nucleotide sequence using Python?
I am trying to solve an exercise in which a function with a start and a stop, where the start should occur when you find "ATG" and the stop when you find the "TAA", "TAG", "TGA". With the help of…
-
3
votes0
answers54
viewsAttempt to compare values from a list in a function does not generate the expected result
I have a function that receives a list and inside it a loop of repetition in order to go through all the positions and compare the value of that particular position with the value that comes by…
-
2
votes2
answers195
viewsHow to load all functions from a folder?
Suppose the folder "D:" has several functions that I use in a project. How to load all these functions with a script?
-
2
votes1
answer227
viewsAction Script 3.0 Function does not receive parameter
I’m having a problem with parameters for my function. It’s not getting the parameter I pass to it. Follow the code below: function gerarescala(e:MouseEvent):void { var tom:String = texto.text; var…
-
2
votes1
answer963
viewsassign a function to a key on the keyboard
I’m creating an application for a cattle auction where has lot, sex of the animal, whether it is the view or the term and the value field of the lot where increases while the auctioneer speaks the…
-
2
votes1
answer76
viewsFunction not defined error
Follows the code: <?php if (isset($_GET['algumacoisa']) && !empty($_GET['algumacoisa'])) { $user = "useradmin"; $pass = "senha123"; mysql_connect("localhost", $user, $pass);…
-
2
votes2
answers21710
viewsHow to create txt with js?
And guys I have a JS that has some functions that takes the name of the player, position, position, level, image etc. I want to save this data in a dB, the user logs in with the account and access…
-
2
votes4
answers1708
viewsPass javascript object by parameter in ajax callback
I know how to string: onclick="popularEdicaoRetrofit(\''+data[i]+'\');" and number: var criarRetrofit = onclick="criarRetrofit('+data[i].idRetrofit+');" I would like to know how to step an object as…
-
2
votes1
answer1139
viewsFirebird - function for decimals and thousands
Is there any native function of the Firebird that returns me the same currency format as the Brazilian or some stored Procedure do this job. Example: #.###,## The point would be the thousand houses,…
-
2
votes1
answer157
viewsFunctions - Model, Controller
In my model I have this function that defines the url format : public function url_format_category($category, $lang_domin) { if (lang('abbr') == 'en_US') $lang_domin = 'en/'; else if (lang('abbr')…
-
2
votes2
answers182
viewsHow to return dates with a zero count
I’m trying to use the function coalesce to return 0 when my query does not have a return value, but I have tried a thousand and one ways and I cannot return 0 at all. I want to know where I’m going…
-
2
votes3
answers173
viewsFunction =VLOOKUP(MAX($B$5:$B$11);$A$5:$A$11;1;0) Excel 2010
I’m using the function: =VLOOKUP(MAX($B$5:$B$11);$A$5:$A$11;1;0) in cell B23 in Excel 2010. Result: #N/A! Can someone help me fix my formula? Thank you very much, Silvio.…