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
votes2
answers64
viewsIs it possible to perform an overload (Overload) with Arrow functions?
I have a function where the return type depends on the parameter type. I was able to declare this overload with function, but not with Arrow Function, because I get the error: Cannot redeclare…
-
3
votes1
answer1401
viewsUsing function to make a subset and plot with only 1 command (R)
My dataframe calls EWMA_SD252 3561 Obs. of 102 variables (daily volatilities of 100 shares since 2000), follows a sample : Data IBOV ABEV3 AEDU3 ALLL3 3000 2012-02-09 16.88756 15.00696 33.46089…
-
3
votes1
answer204
viewsChange the operation of the hook myCRED Gravity Forms
I have a site with a scoring system using the plugin for Wordpress myCRED and Gravity Forms. Mycred offers a hook to automatically give pre-defined points to users each time they send a message via…
-
3
votes1
answer354
viewsjQuery, stop performing functions depending on window size, also in resize
I’m working on a website that calls external JS files. The problem is that when you would like some functions to stop running on desktop when $(window).width() < 800 and vice versa: Link to…
-
3
votes5
answers631
viewsIf Else with functions
It is possible to use a if-else with function "Function();" example: if (a > 1){function Save();} else {function NoSave();} I just need to know if functions are loaded into the head work within…
-
3
votes1
answer236
viewsHow to create a modular function whose parameter is an operator?
Suppose I want to create a function that changes the src of an image by another in the index of an array, thus: var arrayimgs = ["js/img1.jpg","js/img2.jpg","js/img3.jpg"]; var imagem =…
-
3
votes1
answer45
viewsFunctions with public property
How is it possible to use a function as an object? More precisely, I would like to repeat the behavior of $http angular, where it is possible to execute a request in the following forms:…
-
3
votes3
answers677
views -
3
votes3
answers1207
viewsWhat’s the difference when calling a function with parentheses and without in.py urls with Django 1.7?
In mapping my.py urls I use from common functions to class-based views. I want to know the difference between calling the view with or without parentheses, given that if I have the input url(r'^$',…
-
3
votes3
answers273
viewsWhat can change with the variadic Function implementation?
PHP 5.6 implemented a feature called Variadic Function. It is as if they were infinite arguments. They can be used both in the statement of a function as for the calling. Examples PHP 5.6 Example in…
-
3
votes1
answer2746
viewsHow to create a function in R
I am wanting to create a function to control the students' grades. I am trying the following function: note_eng<-read.csv2("note.csv",header=TRUE)…
-
3
votes1
answer190
viewsFunction with nameless parameter
Why to declare a function with that signature? void funcao1(Pessoa&); void funcao2(Pessoa&,void*); void XN_CALLBACK_TYPE UserCalibration_CalibrationComplete(xn::SkeletonCapability&…
-
3
votes2
answers66
viewsWhy does the function return me an unexpected value?
Why this function is returning me "failed"? $nFis = 90 function resFis(){ if($nFis >= 60){ return "aprovado"; } else{ return "reprovado"; } }…
-
3
votes2
answers70
viewsPHP parametric functions
I am new in php and I am creating a comparison of box sizes, and for that I would like to put inside a function more I do not know which parameter to put inside the relatives of the function.…
-
3
votes1
answer433
viewsI’m wanting to display the amount of negative numbers typed using functions
#include <iostream> #include <locale.h> using namespace std; int getnegativo(int a, int b); int main() { setlocale(LC_ALL, "portuguese"); int…
-
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
answer878
viewsPython functions
I did this Python exercise, version 2.7: Instructions First, define (def) a function called Cube (cube) that takes an argument called number (number). Do not forget the parentheses and colons! Make…
-
3
votes2
answers5642
viewsHow to access variables present in different functions?
What is the best way to access a variable that was created in a function? For example: def Luggage(): mala = [] take = raw_input("O que você deseja levar na sua viagem?") mala.append(take) In case I…
-
3
votes2
answers85
viewsCrop image in wordpress and delete the original image
After the upload of an image in wordpress I would like to make a check if the registered image is larger than the stated limit size, if it is larger I want to delete the original image in the folder…
-
3
votes1
answer117
viewsMethod ignoring callback function in jQuery plugin
I am developing a plugin in jQuery and the problem or difficulty is: I created the methods init, show and hide; (function( $ ) $.fn.tooltip = function(method, onClick, onBefore, onAfter) { var…
-
3
votes3
answers1140
viewsMethods with the same name but with a number of different parameters
In C# or Java in a class I can define methods with the same name but with different variables, like this: //em C# public class Classe { public String teste(String hello, String world){ return hello…
-
3
votes2
answers186
viewsHow to return a specific variable from within a Function?
In this code I gave a return $array and I’m using the data inside the foreach, so far so good. I would also like to use the variable $url_controle inside the file I called the function. Question:…
-
3
votes1
answer2127
viewsHow to create image thumbnails of an existing image within the folder?
I’m learning to program, including learning VERY MUCH with the help of you who teach me practically everything about functions and my problem now is this: I need to create thumbnails of several…
-
3
votes3
answers654
viewsHow to loop inside an image folder and resize them?
I have this class in PHP that when running resizes the images contained in a folder. If you observe, the resizing is triggered by these instructions, one for each desired size.…
-
3
votes1
answer443
viewsHow to create function to automate a dynamic progress bar?
I have a form with some "modules" (module = a set of questions - I do not know if it is the appropriate technical term...), so depending on which module is chosen, a certain amount of questions will…
-
3
votes2
answers1740
viewsQuery methods, classes and attributes in the C language
I wondered if in the C language and possible query libraries available their modules classes and attributes as in the Python language that exist the methods dir() and help() i am starting to learn C…
-
3
votes1
answer94
viewsPointer cannot be reset to NULL within function
Hello, folks! I was studying binary trees and needed to create a function that would remove any knot and its children. However, when I did this function with the return /1/ the node has not been…
-
3
votes1
answer504
viewsHow to "concatenate" Javascript functions?
How does jQuery lib? Example: $(element). text('my text'); I want to know how to do a function like text() in pure Javascript, just to learn the theory. I want to know how the html element is passed…
-
3
votes1
answer62
viewsAdd Change Author in Quick Edit Type Post
I created a type post to customize the wordpress admin of a client, everything works perfectly, however the option to change the author of the post in "quick edit" does not appear, I know by default…
-
3
votes2
answers80
viewsParameters for external call
I use Linux and by default (or at least in my case) it does not have screen brightness control, but has a program that gives to control. The point here is that I want to take the "user" value and…
-
3
votes1
answer4789
viewsPass vector by reference or value?
I want to create two functions, one is to fill a vector with random numbers. The other function is to show the contents of the filled vector. So I did it this way: #include <stdio.h> #include…
-
3
votes1
answer85
viewsObtaining different results by passing by value and passing by reference
I’m testing these examples of C codes: Call by value #include <stdio.h> /* function definition to swap the values */ void swap(int x, int y) { int temp; temp = x; /* save the value of x */ x =…
-
3
votes1
answer409
viewsHow to pass an array as parameters or arguments?
I have two functions: function example($param1, $param2) { echo $param1 . $param2; } function frutas($fruta1, $fruta2, $fruta3) { echo $fruta1 . $fruta2 . $fruta3; } And I also have a variable that…
-
3
votes2
answers102
viewsFunction calculates to a certain extent and to
I have a variable double making an account but it reaches a limit [in my case 1.367879] and does not increase more. The code is running normally, the problem is the result that is not more than…
-
3
votes3
answers168
viewsFunction calling other functions
I have a form and 1 function to validate each field of this form function valida_nome() { } function valida_email() { } function valida_tel() { } function valida_senha() { } <form…
-
3
votes1
answer179
viewsReturn of functions in C
A very common and practical thing in interpreted languages is the return of functions from another function. But in compiled languages as well as C, it is possible to return a function?…
-
3
votes2
answers3951
viewsFactorial function in C does not return the result
What’s wrong with my code? int fatorial (int n, int num, int fat) { if(num >= 0) { fat = 1; n = num; while(n > 0) { fat *= n; //FATORIAL = FATORIAL*N n--; } } }…
-
3
votes1
answer148
viewsWait variable value to return function
I’m trying to create a function that turns a file into a Data URL. But I am facing a problem: The return value of the function is not what I expected. Just follow my code: File.prototype.toData =…
-
3
votes2
answers202
viewsDisplaying certain vectors in a 2D Python list
I have the following situation: - I have a variable called (vector_distances). This variable receives a 2D list with several vectors. - I wish it to be displayed, only vectors whose sum of their…
-
3
votes1
answer881
viewsNested Functions in Python
How do I do nested functions in Python? Another question, because I always need to use the self parameter, and I’ve already put parameters in the function? For example, it is considered that the…
-
3
votes2
answers1598
viewsRecursive function call - Python
I have a list of integers larger than zero. I need to identify the one with the largest number of divisors. For this I created three functions: one that lists, one that returns all divisors of all…
-
3
votes2
answers1159
viewsOracle reference the type of a column equal to the type of another column
I’m trying to create a table to return in a function. For this, I am trying to create a object type thus: create or replace type relatorio as object ( planta TABLE_NAME.COLUMN%TYPE, resp_0…
-
3
votes1
answer85
viewsMultiple Function in one file
I have a project in php and within that project I have a folder called Funções. Inside this folder I have several function files. I have a file called Logado.php, where I authenticate the user and…
-
3
votes2
answers4105
views.addeventlistener() is not a function
I’m building a script for modals, but an unexpected error happened, the console says: Uncaught Typeerror: loginBtn.addeventlistener is not a Function`", "at modaisGeral (index.html:233)" and "at…
-
3
votes1
answer131
viewsVariable type of return
I want to do functions with variant input type, like this: int count(vector<auto> base, auto val) { int sum= 0; for (auto it : base) { if (it == val) { sum++; } } return sum; } or this: string…
-
3
votes1
answer179
viewsWhat is the "listw" argument in the multispati (multivariate Spatial analysis) - R software?
It involves spatial dependency, but I’m not sure how.
-
3
votes1
answer1018
viewsError converting from varchar to smalldatetime
In the query below the following error occurred: Conversion of a data type varchar into a data type smalldatetime resulted in a value outside the range. Looking at it, I realized that if I take the…
-
3
votes1
answer601
viewsReturn local function variables
I have two methods: // Apenas define um vetor de 4 posições e retorna ele int *verticesFromFace(int v1, int v2, int v3, int v4) { int vertices[4] = {v1, v2, v3, v4}; return &(vertices); } //…
-
3
votes2
answers1169
viewsValue-finding function between Javascript variables
I have the following form: <body> <form name="questao1" method="post" onsubmit="sendToDB();"> <br><input type="checkbox" name="Q1[]" value="Enfermagem"…
-
3
votes1
answer186
viewsFunction extension on the Laravel
I’m using the Laravel 5.3 and apparently I have a Controller calling the function: (new AnuncioRepository())->getListagemAnuncios() and the SQL for that is: return DB::select(' SELECT anuncio.id,…