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.

0
votes
0answers
6 views

how to use mlmodel to make predictions on UIImage?

I have been working on a project which involves detecting if a person is happy or sad in an image. I am using a machine learning model for this purpose. I have already converted the python model to ....
0
votes
2answers
17 views

i can't show span in function - javascript

i don't know how i can used if inside function then show it by span in html. this my function: <script type="text/javascript" src="praytimes.js"></script> <script type="text/...
0
votes
0answers
9 views

function parameter error with fsolve in python

I have been trying to make a function with a calculation that uses the described function with following fsolve. what I need is to be able to run this calculation as a formula with the possibility ...
0
votes
1answer
13 views

Using Vector of Character Variables within certain Part of the lm() Function of R

I am performing a regression analysis within R that looks the following: lm_carclass_mod <- lm(log(count_faves+1)~log(views+1)+dateadded+group_url+license+log(precontext.nextphoto.views+1)+log(...
-3
votes
0answers
12 views

php function that converts numbers to arabic words [on hold]

I need a php function to convert a number to Arabic words. For example, user types 50, the output should be "خمسون". And for larger numbers as well. Is there is a way to do that?
-1
votes
2answers
34 views

Can't understand why function doesn't work

I'm new to Python3 and coding. I'am get stuck with a simple function. import datetime date = str(datetime.date.today()) mail = "" text = (f""" some text {mail} some text {date} some text """) ...
1
vote
1answer
31 views

In C, iterative function is not giving the right output which is supposed to be a number not in sum(from data entered by user) or in data array?

I am working on an assignment. My assignment is to: Write a program to find the smallest positive integer that does not appear in the array and can not be formed by the sum of two numbers in the array....
0
votes
0answers
28 views

How to rewrite the function so it will return an object that will be rewritten in the outer scope?

I'm trying to write a lottery app with the following logic: The user inserts an array of 6 numbers and number of draws. API receives the information and do the following steps: Generate a winning ...
-2
votes
3answers
27 views

preg_replace_callback_array Doesn't return match calculation value

I try preg_replace_callback_array for math bbcode. Its returning as plain text while i require calculated result <?php $kode = array ( "/\[math\]([0-9+\-\/*\)\(]+?)\[\/math\]/" => ...
0
votes
1answer
15 views

Python program to convert miliseconds to hours,minutes and seconds logical error

I am learning python and I have a program that converts miliseconds to hours,minutes and seconds. I am getting an incorrect output that's different from the sample run. Here is the question and sample ...
2
votes
5answers
32 views

python: how to change the value of function's input parameter?

I tried to modify the value of a string inside a function, like below: >>> def appendFlag(target, value): ... target += value ... target +=" " ... >>> appendFlag <...
0
votes
0answers
9 views

Python: Empty dictionary in function definition undesirably retains items from previous function call [duplicate]

I got a strange bug recently. I had written a function that took a dictionary as a key-word argument, the dictionary was set in the function definition to be empty by default, and yet it would ...
0
votes
2answers
31 views

How can you add entries, and retrieve, alter, or remove values from specific keys in any nested dictionary without recursion?

I was working on a cool project I am doing in Python and I needed a way to do this without recursion because this would limit the size it could be by limiting the amount of times the loop could go ...
0
votes
1answer
26 views

Recursive Function: recursion with python

I have this Function: def depth(self): if self.root == None: return 0 left = depth(self.left) right = depth(self.right) if left>right: ...
0
votes
1answer
17 views

Radio buttons and functions

I am programming an inspection form. I have a lot of radio buttons and I want, when a button is selected, to allow another field to populate a point value. For example, Radio button name = 2.5 Green. ...
0
votes
2answers
31 views

Generic function with proper signature

I don't know how to declare second parameter of function boom to have proper type checking, I mean if somebody is sending to function boom first parameter as "foo1" then the second parameter should be ...
0
votes
1answer
20 views

Apache/PHP undefined function curl_init()

I have this error message when I compile my program in PHP. I have these two lines in my php.ini file : extension=curl extension=C:\Server\bin\PHP\ext\php_curl.dll It still doesn't work, can you ...
2
votes
1answer
34 views

Execute function via jQuery

On my site I have a number of links to various external booking forms that should open in new windows. Unfortunately I can only change each links class (can't set the Id's). What I'm trying to do is ...
-1
votes
1answer
54 views

How to create a unique name in a dataframe for similar strings? [on hold]

This is my current dataset. persons<- c("James", "Michael", "Michael", "Robert", "Richard", "Harry", "Harry", "Ben", "Michael", "Harry") Since the names here are common. I want to make every name ...
-3
votes
0answers
34 views

Is this code effective when it comes to recursion? [on hold]

I'm suppose to write a function that receives 3 pointers of 3 strings. two of the strings can be empty the other one will include a mix of numbers and letters, for example "He6l9lo3". I need to go ...
-1
votes
1answer
23 views

Troubles with simple pokemon battle in C#

I'm making a very simple Pokemon battle game with C#. The main idea is that every 5 turns the first Pokemon (Squirtle) powers up his damage with a function. But when I compile it, the damage of ...
-1
votes
0answers
12 views

PHP trouble: Object function inside include cuts off document [on hold]

I'm including one of three different bodies of information based on the $_GET like this: if(isset($_GET['start'])){ include("includes/startContent.php"); } if(isset($_GET['user'...
-1
votes
1answer
16 views

Export variable from an immediately invoked JavaScript function [duplicate]

I am trying to export a variable from an immediately invoked JavaScript function. I need that variable to be imported in other components of my project. I am using Angular CLI for development. I have ...
-2
votes
0answers
29 views

How to create a shared pointer or unique pointer based on argument in a function and return it? [duplicate]

I am trying to create either a std::shared_ptr or a std::unique_ptr based on whether my function's argument is true or not. If the argument in my function is false, I want to own the pointer so that ...
0
votes
0answers
15 views

Defining a position function that is dependant on time:

I am creating a simulation of 5 free falling balls that bounce with one another. I have the collision detection and the collisions done. But I am having trouble with defining the typical free falling ...
0
votes
2answers
38 views

How do I apply this string length function to a column in my dataframe?

I have written a function that returns the length of a string, def string_length(): string = input("Please enter a string: ") """This prompts the user to enter a string""" return(len(string)) I have ...
0
votes
2answers
15 views

Django function execution

In views, I have a function defined which is executed when the user submits the form online. After the form submission there are some database transactions that I perform and then based on the ...
0
votes
1answer
31 views

Servlet doesn't respond properly after sending request

so i have this simple website in jsp that contains todo list, i've already made Add functionality but now there's a problem with delete function. <ol class="list-group"> <c:...
0
votes
0answers
31 views

How to loop over a lists after using the split function in R

My R skill is still at infancy and I am trying to loop over a calculation but I am not getting the right solution. I want to perform the following operating 30 times l1 = kak[dat1[[1]]$d1,dat1[[1]]$...
0
votes
1answer
37 views

using lapply on a data table within a function in R

I'm currently working on a piece of code that would calculate how many observations are lost within a group of study participants, if a certain data cleaning criteria is applied. This specific example ...
3
votes
3answers
41 views

javascript better way to create object with a method using function

I'm new to javascript and am trying to create an object that I can then fill a list with instances of. This code I have works, but it feels redundant to have the "this." keyword on every line. Is ...
1
vote
1answer
30 views

slow function by groups in data.table r

My experimental design has trees measured in various forests, with repeated measurements across years. DT <- data.table(forest=rep(c("a","b"),each=6), year=rep(c("2000","2010"),...
0
votes
0answers
13 views

Create columns like some sort of contingency table based on a solution variable [duplicate]

As my previous question about this topic from a month ago was not yet answered completely and I am missing 1 reputation point to add a bounty, I decided to ask it again with some added information. -...
-1
votes
1answer
28 views

computing future investment value in python error

So I am trying to solve this problem; The image contains some sample output. This is the code I have so far and I'm not sure where I am going wrong. Problem is it is not displaying the correct ...
0
votes
0answers
46 views

A php function for an html select box [on hold]

I need a php function to populate my form select boxes in. First of all, take a look at the following piece: function dbSelectBox ($tag_name, array $inputs, $name, $id, $session ='1') { if (...
0
votes
1answer
49 views

How to pass variables to function as a vector? [duplicate]

I want to use 3 variables in the form of a vector inside a function, for example the variables: L (length), B (breadth), H (height) Instead of the usual case: volume <- function(D,B,H) { vol &...
0
votes
1answer
36 views

Repeating animation with execute function and UI update

I am making a game like AdVenture Capitalist and i am encountering this problem. I have one label that has just text in it, that label never changes. I have one animated label that has the same ...
0
votes
0answers
21 views

javascript: use function result outside of function [duplicate]

Hi I am new to js and apologies if I'm asking a simple question. There appears to be much discussion on this topic, but I am as yet unable to comprehend the solutions offered. I want to determine the ...
1
vote
2answers
44 views

How to search for <p> by id for condition in Javascript, and then output text in another <p>?

Sorry, I tried to search for an answer, but I couldn't find exactly what I was looking for. I am trying to make and webpage using Javascript, and I need some sort of decoder. For example, I have one ...
0
votes
0answers
33 views

R : Function to pass variables in a dataframe into a vector not working

So I am very new to R and have been trying to cram some R knowledge into my brain for a project at my work. I am still learning the basics and can't seem to figure out why my function will not run. I ...
1
vote
2answers
34 views

How to draw bullets from player in vanilla Javascript?

I am trying to make an upward scrolling style arcade shooter game. I have gotten stuck on how to draw bullets upward from the player to where the enemies will be. I am using setInterval to repeat the ...
2
votes
4answers
49 views

Pasting values from different columns and different rows into a new df in R

I have the following df below: name name..2 IGD 1 yaaA recF 16 2 recF yaaB 18 3 yaaD yaaE 22 4 dck dgk -3 5 dnaX yaaK 24 6 yaaK recR 15 7 recR yaaL 18 8 xpaC yaaN ...
0
votes
1answer
37 views

Reduce function arguments into a vector

Hello I'm simulating from a function defined with a dozen arguments: library(tidyverse) rmixexp <- function(n, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, m1, m2, m3, m4, m5, m6, m7, m8, m9, ...
0
votes
1answer
21 views

How can I pass parameter to a function called in Python vegas library?

I am trying to integrate over some function with vegas library, a simple implement that integrates f(x) = lambda x: x ** 2.0 is import vegas f = lambda x: x ** 2.0 integrator = vegas.Integrator([[0.0,...
1
vote
1answer
34 views

filter functions keeps failing with missing data argument

I am working on Marketing Mix Modeling and I am following the article https://analyticsartist.wordpress.com/2014/01/31/adstock-rate-deriving-with-analytical-methods/ The article defines the adstock ...
0
votes
1answer
19 views

Why cant my qqnorm graph run as part of a function or within brackets?

I am attempting to tell R to run multiple lines at a time using "{ }" brackets. I have done this with success before. I am attempting to generate multiple plots at a time by defining several plots in ...
0
votes
1answer
29 views

Error in estimating pi by Taylor expansion

I am trying to calculate the value of pi, but there is some semantic error in my logic which I am not able to figure out. def taylor(precision): iter = 1 sum = 0 fx = 100 sign = 1 ...
1
vote
0answers
32 views

how to insert into a table from another table and also using a function

I tried below but I got violation of Primary key. insert into a_c ([a_id], [C_id], [ac_id]) select t2.A,t2.C , dbo.getac_id() from table_2 t2 I also tried using cursor it did not work. ...
1
vote
0answers
23 views

Declaring the same function in different ways change the compilation code in Javascript [duplicate]

I'm facing a bug in a program where I decided to use the ES6 ways to declare a function. const fun = () => { } And I've always thought this was the exact equivalent of const fun = function() {} ...
1
vote
1answer
34 views

Java function call with changing parameter amount

I have a question. While my program is running I get a request with parameters (i don't know the exact amount in advance), a function name and a class name. I load the class at runtime and want to ...

http://mssss.yulina-kosm.ru