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
-
2
votes1
answer1893
viewsDoubt to create and work with JAVA class array
I have a program with 2 classes. The player class contains only the name attribute: public class player { String name; } And I have the Main Class that has the function below and the call of the…
-
2
votes1
answer48
viewsHow to take the value of multiple items and change according to my if
I have a list of items (that comes from the database), I need to compare each item of one of these and if the value is 0 change the text. Below is the function I’m trying to use to change the value…
-
2
votes0
answers175
viewsUpdate within a mysql function
I have to do a process to perform an update on a given table field. I created a function in mysql. But within this function would need to perform an update, but the non-accepted function would have…
-
2
votes2
answers487
viewsHow to use the return of a function in another Python function
I’m new in Python and I’m not being able to use a return of a function in another function in the sequence: I’m putting a fictional example just to describe my doubt: def…
-
2
votes1
answer276
viewsHow to modularize the following code C
Below follows a code for date entry by the user and validation of it, but would like to modularize it. I don’t know if there is a possibility to use it outside of the box, or in an external file…
-
2
votes2
answers130
viewsFilter through the href
Well, I’m new to using Javascript and I’m having some difficulties. I have a box that has 6 links, this involved in a gift-repeat, IE, are many 'boxes' with 6 links inside. I need to check if inside…
-
2
votes1
answer263
viewsHow do I pass the first char address of a string to a function to write to it?
The problem is this: I made a function that takes the output of a given OS command and stores it in a string. The idea now would be to declare a single char string in my main function using malloc,…
-
2
votes1
answer665
viewsConvert File string to Float
The program below should take the data written in a file . txt, show on screen and do the general average calculation. the data in . txt are being saved in the following format: Student: Bruno First…
-
2
votes1
answer153
viewsDelphi 10.1, Function that only accepts an integer interval in the variable
It sounds easy, but I’m not getting it. I want to be able to define a type of variable when creating a Function or Procedure, but only accepting integers between 1 and 4 for example during the…
-
2
votes2
answers161
viewsPointer for C functions is not calling
I’m having a problem with function pointers. I declared the pointers and stored them in an array, but when calling the functions through the pointers the compiler has an error that I have not yet…
-
2
votes2
answers295
viewsMigrate PHP function from mcrypt to Openssl
I have a PHP function that uses mcrypt. The problem is that PHP 7.2 no longer accepts mcrypt... Does anyone know how to redo it to get the same result using Openssl? function Encript($Val, $chave){…
-
2
votes2
answers41
viewsWithin a method belonging to an object, the this of the called function does not point to the object
I have a function: let comparaComThis = function (param) { console.log (this === param) } And I have an object that calls this function: const obj2 = { consta(){ comparaComThis(obj2) } } The point…
-
2
votes1
answer53
viewsWhy do different types of variables give different results when modified in a function?
I can’t understand why x and v[0] are different. void edit1 (int x) { x = 9 * x; } void edit2 (int v[]) { v[0] = 9 * v[0]; } int main () { int x, v[2]; x = 678; edit1 (x); printf (" x: %d\n" , x);…
-
2
votes2
answers130
viewsLocal variable declaration in a PYTHON function
def fib(n): a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a+b print() result-> 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 But if I declare the variables a and b in different…
python python-3.x function variables variable-declarationasked 6 years, 8 months ago Rafael Eduh 51 -
2
votes1
answer237
viewsHow to sort an array by the frequency of appearance of each element?
Not to delay too much I go straight to the point, I am trying to make a program for an exercise that possessed the following instruction: Build a function int ordenaFreq(int v[], int n) efficient,…
-
2
votes1
answer238
viewsHow to pass a dynamically allocated struct to a C function?
The program must dynamically allocate the struct and pass it as parameter. #include <stdio.h> #include <stdlib.h> typedef struct cadastro_de_mercadoria{ int codigo; int estoque; }…
-
2
votes1
answer693
viewsFunction to return months of year sql server
I’m new in sql server and would like if possible a help with an exercise I’m doing. I have a query that she returns me the region of a resale, the name of the resale, the cnpj, the registration date…
-
2
votes1
answer46
viewsHow do I build the Summary() function in R for a data frame?
I’m trying to do it this way dados<- c(10,18,19,15,21,34,45,64,20,21,39) resumo <- function(x) { min(x) max(x) n <- length(x) s <- sort(x) ifelse(n%%2==1, s[(n+1)/2], mean(s[n/2+0:1]))…
-
2
votes1
answer1093
viewsList folder and subfolders in a PHP foreach
I’m using the library Comic to extract information from a file .torrent, the idea and lists the information of the torrent files in a table using the foreach, however during listing, files that are…
-
2
votes1
answer39
viewsConfusion in access to vector size in C bytes
In the code below: #include <stdio.h> void testaTamanhoVetor(int vetor[]) { printf("tamanho do vetor em bytes na funcao: %zu", sizeof(vetor)); } int main() { int a[10]; printf("tamanho do…
-
2
votes3
answers105
viewsHow to change the value of a variable with a function?
var x = 2 function alterar(x) { return x += 2 } alterar(x) console.log(x) console.log(alterar(x)) Why the variable x doesn’t change the value? It only changes when I call the function, but then it…
-
2
votes1
answer55
viewsHow to filter the input of a form to the Database?
I have a function to filter input data to send to the database, I’ve been looking a little while and I thought that still has to improve, the default that I use is UTF_8, the data comes from forms…
-
2
votes1
answer704
viewsHow does Python handle common functions and internal Python functions?
I’m looking at Python’s dual functions compared to the common functions that use def to create them. See an example of a common function that converts a number to binary: def…
python function characteristic-language lambda-expressions python-internalsasked 6 years, 1 month ago gato 22,329 -
2
votes2
answers61
viewsPass X function as parameter to Y function, but only define X parameter within Y
Does anyone know how to make the code below work? Or some alternative that works, but follows the principle. def f_numbers(number='no'): if number == 'no': return 'Você não definiu um número' else:…
-
2
votes2
answers739
viewsreturn python function variable
I have a function that returns several values, and I wanted to pass two of them out of the function, but when I try it returns that the variable outside the function has not been declared. To…
-
2
votes1
answer95
viewsObject does not recognize member
All I do is in Python. One of the functions I have to do is a conversion, where she tries to convert the value of TextBox and if it goes wrong, run the error block. private void converter(object…
-
2
votes1
answer44
viewsRun function 1x per click (Javascript)
I have a button where his job is to mark one pixel on a div. However, after I click the button, in case I click several times on the image, it marks several pixels. How do I limit this marking to…
-
2
votes2
answers92
viewsA - How to display repeat progress ? And processing time?
Hello ! I am importing a database by Chunks and making filters. I use this code that I took from someone here and adapted to my case: arq_grande <- file("cnpj_dados_cadastrais_pj.csv", "r")…
-
2
votes3
answers4032
viewsPython, even and odd number counting
Create a program in Python that, for any list of integer values, gets (through functions) and prints on the screen. The number of even and odd values in the list. I’m doing a program like this, but…
-
2
votes1
answer284
viewsI try to run a python function and it returns me None
Sorry if my question seems silly I’m still novice but it’s the following, I created a python function that should return me a list with this character in "~". Here is the function: def…
-
2
votes1
answer48
viewsFunction to create charts per column
I’m using this code to plot age pyramids: p_etarias <- read.csv(file "C:\\Users\\User\\Desktop\\DemandasCEInfo\\20200327_CNSAÚDE\\Piramides\\R\\p_etarias.csv", sep = ";",dec = ",", header = TRUE)…
-
2
votes1
answer112
viewsMounting ranking with sorting criteria with array
I need to sort this Array initially by points and if there is a tie, those indexes of the array that tied would be unpacked in the games, if it remained tied would jump to tiebreak and if it…
-
2
votes1
answer102
viewsShould I specify the type of return of a procedure in Python?
For some time I have studied and learned a little more about Python. I recently read an article about the description of python typing using the module typying. Since I learned about this feature I…
-
2
votes2
answers678
viewsJavascript functions: One function inside the other
1 - I have to create two functions inside each other. 2 - The first function has two parameters. 3 - The second function has a parameter. 4 - I followed the problem statement: 5 - Declare a function…
-
2
votes2
answers40
viewsHow to apply a function with "foreach", using a set of pre-selected items by the Jquery style selector?
I do not know if I could be clear in the title, and so I will illustrate. In jQuery, we could do something like this to make all H2 green: $('h2').css('color','green') I’m trying to get rid of…
-
2
votes2
answers165
viewsAnswer coming out only true for all elements, or false
I was solving a question where there are two functions. The first function is to know if the value is true or false with two parameters, if it is equal to or less than the second parameter will be…
-
2
votes1
answer83
viewsHow do I return a character from a string in the Python function with Websockets and json library?
I’m new to Python and I have a question I’ve been trying to figure out for a long time. I’m creating a tick analysis program from an investment site, and I want to extract the value of a certain…
-
2
votes1
answer65
viewsPython - Object-Oriented Programming
I created a module with two classes: I want to use both as if the mouse depended on the computer. E.g.: when using them: only when the Computer is turned on does the mouse have permission to turn on…
-
2
votes2
answers52
viewsCall and apply methods in functional composition
I wanted to know how the methods call and apply behave, especially when one is passed as argument from another, and understand some of the logic of this code, mainly in the line in which they were…
-
2
votes1
answer302
viewsCheck that the string only contains Python letter and space
I want the user to enter their full name, but if they put something other than letters, it should display an alert message. The problem is that the user’s full name requires space between words, and…
-
2
votes0
answers34
viewsAnonymous class receiving a value through a function
Guys, here’s the thing, I just came across a situation that I didn’t quite understand how it works. Some objects such as the components in the Java Swing, or any type of frameworks objects that have…
-
2
votes3
answers104
viewsSyntactic difference between classes and constructor functions in Javascript?
I’m studying Javascript and I noticed that, in the constructor functions, we can declare variables and constants. For example: function Teste() { const nome = 'Bruno'; this.nomeAtributo = nome; }…
-
1
votes1
answer412
viewsUndeclared variable error
I have variable declension problem in my PHP function. Error message: Notice: Undefined variable: extra in path functions.php on line 58 The function: function show_users($user_id=0){ if ($user_id…
-
1
votes2
answers207
viewsMethod and Sub-programme
Both mean the same thing? void subrotina(){}; Isn’t that called method too? People don’t say they’re going to do a subprogram that does something, usually people say, "I’m going to do a method that…
-
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
answer478
viewsError when finishing Activity through another class
Can anyone explain why the error occurs LISTADO NO FINAL DA PERGUNTA, terminating the application, when I try to finalize the application through another class: Classe1.class: ... ...…
-
1
votes2
answers582
viewsHow to create a function that returns the lowest expiration date between batches of a given product?
How I create a function that returns the shortest expiration date between batches of a particular product? Dry my SQL code: create database Exemplo; use Exemplo; create table produto (codProduto…
-
1
votes1
answer161
viewsFunction that returns pointer gives crash when trying to return pointer to main program
I have this function that retrieves a record from a binary file already filled with records - such records are structured as Node - and returns it to the program. Only in the return of "i" for the…
-
1
votes1
answer86
viewserror when converting an Oracle precedent into a Postgresql function in pl/pgsql
I adapted the code, but there is the following error : ERROR: relation "fields" does not exist CONTEXT: compilation of PL/pgsql function "p_grava_log" CREATE OR REPLACE FUNCTION F_GRAVA_LOG ( TIPO…
-
1
votes1
answer4690
viewsObject as parameter in a Javascript function
I have looked in several places about the use of object as a parameter in a function, but only found on that website, but I didn’t feel comfortable with that structure. how best to put an object as…