Questions tagged [function]

A function (also called a procedure, method, subroutine, or routine) is a portion of code intended to carry out a single, specific task. Use this tag for questions which specifically involve creating or calling functions. For help implementing a function to perform a task, use [algorithm] or a task-specific tag instead.

1
vote
1answer
19 views

Function within a function for iterating each rows based on a column value

I currently am trying to create a function for a dataframe and is too complex for me. I have a dataframe that looks like this: df1 hour production .... 0 1 10 0 2 ...
0
votes
1answer
22 views

why is method within React Component function constructor evaluating after the components have been initialized?

Sorry if the title is hard to understand, because it's definitely a weird problem. I think this screenshot best explains what's going on, and it makes no sense to me in every sense of programming. ...
0
votes
0answers
17 views

ast matcher for unused return value

I am trying to match functions that have return values, but are not used. Something like this: int foo(int a) { return 0; } int main(void) { foo(5); -->> replace with (void) foo(5); return 0;...
1
vote
1answer
15 views

Is there an R function for subtracting values in a variable by group based on specified conditions?

I have a df that takes this general form: ID votes 1 65 1 85 2 100 2 20 2 95 3 50 3 60 I want to create a new df that takes the two highest values in votes for ...
0
votes
0answers
16 views

How do I pass a variable defined as (Entry.get()) from one function to another?

How do I pass the (Answer) variable from creatLabels function to check function? def createLabels(Ques): AnswerINP = Entry(root) AnswerINP.grid(column=3, sticky=W ) Answer = AnswerINP....
-1
votes
0answers
48 views

Function return as a parameter (constant reference) of class initialization?

The simplified problem is(with the code below): class_B has no default constructor, so B1 and B2 have to be constructed at the same time of class_C's construction. While the first parameter of B2 ...
0
votes
1answer
15 views

I'm creating a code to greet me based on time of day and for some reason it can't distinguish my name from other text

I'm coding a simple script that greets based on time of day when I typing my own name into the prompt and will give a message stating otherwise if it's not me. var name= prompt("What is your name?");...
0
votes
0answers
27 views

Python 3.7.2, end = “ ” in my for loop removes all text when ran in console?

I am creating this encoding/decoding program in python. (3.7.2). You input string into the program, it converts it to a list, reverses the list, switches some items around to make it more cryptic. The ...
-1
votes
0answers
14 views

Can't figure out why matplotlib functions aren't applying to graph?

I'm working on some research stuff and got the plot about to what I needed but the axes labeling just isn't working no matter what I've tried (plt.xlabel(),plt.ylabel(), ax.set_xlabel(),ax.set_ylabel()...
0
votes
1answer
15 views

Calculator in JS

I was trying to make a really simple & basic calculator with JS. For the "addition" portion of the calculator the numbers that are put in won't add properly... FOR EXAMPLE: 12 + 12 comes out as "...
0
votes
2answers
20 views

Unable to drag two added elements through DOM to different locations

I'm trying to create a kanban (trello-like) simple website to learn javascript. I have gotten the drop-and-drag functionality to work, I am, however, struggling to add a new card, and move multiple ...
-2
votes
0answers
19 views

How to import and extract data from file? [on hold]

We have a problem with importing data from given file (https://dropmefiles.com/1dfsG) and extracting first two columns (we only need those columns). We are expected to import data using function ...
0
votes
0answers
17 views

How to use .map() function by using REACT?

i want to make each Link and name by using map function. for example, 1. name - self, link ="/", 2. name - discuss, link="/discuss" const sections = ["셀프 소개", "미팅", "토론의 장", "건의 사항"]; const links = ["...
0
votes
0answers
27 views

My function works for click event but keyup (JQuery)

I have a weird problem. I have a function that works for 2 different divs. When I click a button that function fires, it's OK. But same function doesn't work for another div's keyup event. function ...
0
votes
2answers
34 views

Is there a way to identify if a word has the same letters next to each other?

I'm trying to create a function in python does specific functions with a list of words in a text document. All the other functions work so it is not a problem with the word document. This function i'm ...
0
votes
1answer
34 views

Problem with self-invoking functions calling other functions

In my index.html file (before closing body tag), I want a function to self-invoke itself when the page is loaded. However, I am having issues when the function (here, setUp) is defined in an external ...
2
votes
4answers
64 views

Need some clarification on a JavaScript lesson. (Constructor Functions)

I have the following code I need some clarification with. I want to understand it perfectly before I move on. I know the example might be silly and I am sure there is a lot of better ways to solve the ...
-4
votes
1answer
31 views

C function-definition is not allow why? [on hold]

I want to run the very very simple library system code. It seems the code is totally true but i dont know why the code dosent work correctly. It gives me 2 error : a function-definition is not ...
2
votes
1answer
40 views

Can anyone figure out why addEventListener on my div is not working?

I am trying to add a listener to a small button like div so I can eventually change the color once clicked without having to use an actual button for different reasons. I have seen multiple people on ...
1
vote
0answers
27 views

Way to load all functions in a package in R?

I am attempting to take a function and apply it in a slightly different way in my own function. However I keep running into dependency issues, such and such function not found. This in spite of the ...
1
vote
2answers
26 views

How do I use user input, obtained through a function, to alter global variables?

I have a global variable that needs to be altered by user input generated by a function. I'm trying to make a Zork style text game and want the character name, input by the user during a character ...
0
votes
0answers
12 views

Proper way to pass malloc 2D array to a function

Sorry if this is a silly question. I have created an array in the main() function int (*n)[properConfigs] = malloc(Nbp*sizeof(*n)); When I fill this array inside the main() function, the code ...
1
vote
2answers
63 views

Call a method of class inside a thread in C++

How can I call a method of class inside a thread? I have a simple method of class and a simple thread... How can I execute de method inside a Thread? Follow the code... #include <iostream> #...
0
votes
0answers
36 views

Can't pass a function as an argument Matlab

i'm studing matlab and I get some problem with a code. First, I've created f1.m: function y = f1(x) y = exp(x) - pi; end Then, I built a code to find the roots by bisector method: ...
-3
votes
1answer
32 views

GO append array multi return func

Using Golang I am trying to append text data to an array but I want to do it efficiently. I have the following snippet var buffer []string var line string for { line, err = reader.ReadString('\n'...
0
votes
1answer
18 views

Does a try affect functions called inside it in python3?

I have some functions that I call inside a try. This try catches a KeyboardInterrupt. Currently the try doesn't affect the code executed by the functions that I call in it, and I was wondering if ...
0
votes
2answers
20 views

problem with for loop over array inside trigger function

I'm trying to put a trigger on a table. This table has a body column with type text. The text in this column can contain @{username} mentions and I need to extract them and write them to the database ...
1
vote
1answer
19 views

How to fetch a sys_refcursor to an asociative array table in PL/SQL

Having this definitions: TYPE type_record1 IS RECORD( id NUMBER, value NUMBER ); v_count NUMBER; TYPE tp_arr_record IS TABLE OF type_record1 INDEX BY PLS_INTEGER; v_t_arr_record tp_arr_record; ...
-2
votes
1answer
24 views

Why is is saying volume not defined?

Getting an error of illegal return statement on the volume... tried adding CuboidMaker15.volume to call the object class CuboidMaker15 { constructor(cuboidMaker15Attributes){ this.length = ...
1
vote
2answers
35 views

How to get data from a pl/sql function if a parameter have more than one value in function with single parameters

I am developing a procedure in pl/sql that get a data set from a cursor executed in a function. For example: Function: f_process_data(id_process IN NUMBER, id_product IN NUMBER) Returns : ...
-1
votes
0answers
26 views

Division in Ruby puts wrong result using const as base [duplicate]

I'm setting up a super simple division in ruby. One number is a const the other number is variable value (pre calculated). currently the culc looks like that: value1 (variable) / value2 (Const) e.g....
0
votes
2answers
36 views

Nothing returned when I try to scrape mlb.com transactions using rvest

I've been trying to scrape the mlb transactions page (http://mlb.mlb.com/mlb/transactions/index.jsp#month=5&year=2019) for the corresponding date and text of every given transaction with no luck. ...
1
vote
2answers
8 views

Using list of strings to execute functions with arguments

I would like to use a list object to call functions by name, passing arguments to each function, while list is used in a loop. The functions have to be referenced as strings as in the actual scripts ...
1
vote
2answers
24 views

Transmit the Classname to a function

I have different "Profiles" in a Json-File. In an index.html different profile cards are shown and filled with the information of the Json-File. When you click on a Profil (Profil-Card) a detailed ...
0
votes
1answer
21 views

Is it possible to create a user-defined function that takes reactive objects as input? How do I do it?

So, I've been on google for hours with no answer. I want to create a user-defined function inside the server side that takes inputs that I already know to wrap reactive({input$feature)} but the issue ...
-3
votes
1answer
30 views

Globals doesnt work inside function Python [on hold]

How can I make work globals inside of function ? I have tried this example0="result1" example1="result2" example2="result3" example3="result4" example4="result5" def newFunc (number): print(...
0
votes
1answer
34 views

how to calculate the stock worth using a function in python

So I have tried running my code this far and it keeps on giving me an error. I need to calculate the total stock worth but I am stuck and really confused on how to move forward. #a list of items in a ...
0
votes
0answers
10 views

Invalid type argument of unary '*' (have 'double') what does this mean?

I'm trying to understand pointers and void functions, I have only been learning C for 9 weeks and functions have gone over my head a little. An explanation would be great as to why I'm getting this ...
1
vote
1answer
42 views

Uncommon function definition in the 'less' program source [duplicate]

My friend asked me could I add "frozen top line" feature to the standard less *NIX program. I started to view the source and was very surprised in function definition the filename.c: public char * ...
0
votes
0answers
15 views

automatically compute a range of lags for all columns in a df and compute each lag correlation with a target column

I am trying to determine, for each feature column in a dataframe, the optimal lag which has the highest correlation with a target column in that same dataframe To do this, I'm trying to construct a ...
4
votes
3answers
109 views

Returning float in void* function

I'm learning how pointers works, but I don't understand one thing in this code. Returning int in void* function works like a charm, but returning float does'nt. #include <stdio.h> void* ...
1
vote
1answer
15 views

Python use every element in ndarray as param for lambda function

I'm trying to calculate the vector basis for any transformation in R^n -> R^m. In order to achieve this I wrote lamba functions to represent the actual function. Some samples are: R2 -> R2: g1 = ...
1
vote
2answers
40 views

How to find the two largest disjoint subarrays of a given length?

I need to write a function that takes in as input an array A of positive integers, a positive integer B and a positive integer C. The function should then return the total sum of the elements of two ...
0
votes
0answers
12 views

Please i have a problem with The function, whenever i click the checkbox it dosen't disable for me to type in something [duplicate]

How can i Make the text box disabled when i click the checkbox? var1 =IntVar() var1.set(0) E_Rice=StringVar() E_Rice.set("0") def chkR(): if (var1.get()==1): txtRice.configure(state = ...
3
votes
6answers
94 views

array.splice = what does it means?

I would like to understand the meaning of that code fragment. "saveTo" is a array, the programmer assigned a function() to the splice method. I don't understand what does it mean. Is that a override? ...
0
votes
0answers
27 views

How to manage multiple conditional return values [on hold]

Depending on a state a CSS shall be applied for my object. <div class="object" data-status="{{object.status}}"> ... </div> How can I handle a growing number of conditional states ...
0
votes
1answer
30 views

Getting an "unexpected '}' error when writing a function and can't tell why

I'm writing a function, which I've never done before. I want to take a table generated by prop.table() and add the first two cells together. I think my script makes sense, but I keep getting an "...
0
votes
1answer
10 views

Iterating through values from CSV and concatenating them with timestamp

I'm trying to concatenate value imported from CSV with a timestamp (to create a filename). It seems that when I try to use foreach with the $csv it loops through all values within one iteration. $...
0
votes
2answers
31 views

How to print function's output as a vector?

I have to create a function called vast that prints leap years between year1 and year2 as a vector. So this is the code I have been using: vast <- function(year1,year2) { year <- year1 for(...
-1
votes
0answers
9 views

Why it is not possible to select an activation function on the output layer of the sklearn MLP regressor?

I would like to select an activation function on the output layer of the sklearn MLP regressor but it is the identity by default. However, in the MLP sklearn class it is easy to select an activation ...

http://mssss.yulina-kosm.ru