Newest 'function' Questions - Stack Overflow

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.

2
votes
1answer
8 views

How do I pass a variable from a function to a sub? Values generated by Function are not determined by variables defined in Sub

I want to use a function to select a random number between 1 and 31, and based on the selection, assign a "box" value. Random results 1-16 are Box 1, 17-24 are Box 2, etc. Within the Sub, I want to ...
0
votes
2answers
25 views

Question: Smart to write sql queries in a function or write different queries apart from each other? [on hold]

For a few weeks i have been wondering if it is smart to write a single function for a mysql query with parameters and variables, and than (re)use this function everywhere on a website where a sql ...
0
votes
0answers
22 views

A function using parameters but not included in declaration? [duplicate]

I was just wondering if it was possible to write a function in JavaScript without having any parameters in declaration parentheses but actually using them inside. For example in below, the function ...
0
votes
3answers
37 views

Backwards loop only printing undefined

I am attempting to create a function that can take in an array and display its contents backwards. I am having trouble with understanding why my function call is showing undefined when I enter an ...
0
votes
1answer
20 views

How to call a javascript function parameters in the table

I have written this javascript function to display information from Database>> RESTAPI>> front end. I tried using document.getElementById("id01").innerHTML = out; but it's not helpful var ...
0
votes
0answers
21 views

How to set many functions using the same variables all at once?

I have many functions all using the same 2 variables (u,v). I am trying to find a way to be able to initialize all these functions all at once by entering the the value of (u,v) only one time instead ...
-9
votes
0answers
19 views

i use determinant function from another program [on hold]

i use determinant function from program 2 in program 1 and create program 3 both of 1 and 2 is correct but case 5 in program 3 not work correctly and answer not right so whats problem?? http://uplod....
0
votes
0answers
14 views

How can I find the power consumption of my function in Watt implemented in my C++ program using Rapl Tool

I am working on an assignment in which i have to calculate the CPU Power consumed by my C++ program (for particular function implemented in it). I found Rapl tool and seems to solve my problem. But I ...
0
votes
1answer
26 views

Troubleshooting the use of if/else inside a event function

I am having trouble using an if else to achieve a simple two-way celsius/fahrenheit conversion using basic HTML input fields and some background Javascript. Basically, I want to be able to enter a ...
0
votes
1answer
28 views

Can map() take functions with multiple inputs?

I want to loop glm/lm over multiple outcomes and predictors while stratified by groups. nest() and map() functions from purrr package seems to provide an elegant solution to stratification analysis. ...
0
votes
0answers
13 views

How would I pass a data variable as a paramater in VueJs? Trying to prevent the value from going empty when changing another prop

I'm trying to dynamically change the value of my prop "quantity" without resetting the other prop values to empty. I have a solution that works but it's hard coded, I believe I know solution to the ...
1
vote
1answer
16 views

Wrong value when using First_Value function in Mysql

I need to prepare a report based on this table, which I can only read: The idea is to have the last value for each observation based on higher activity identification. For instance, value for ...
0
votes
0answers
5 views

How to connect to Azure function which is configured for Azure Active Directory authentication from Dynamics CRM

I have created an Azure function. With no authentication configured, I'm able to create a webhook for this function in Dynamics CRM (using Plugin registration tool) and call the function. but now, I ...
0
votes
1answer
26 views

Slug input field checking function doesn't work properly

My slug url is made of title so I have basic Slug function and one of my own who checking slug input field is/not empty and do some action, but it doesn't work properly.. so maybe someone have some ...
0
votes
2answers
47 views

Export to CSV missing first record, using C# function

Trying to export to CSV, everything works, however, the top row is missing on all exports. This row is not missing when exporting the same record to Excel or KML. Tried re-writing the function and ...
-1
votes
0answers
59 views

My Javascript code does not return any value

I'm a noob of javascript. I need to make some changes in the code but it doesn't return value on keyup. Please help me with this. Thank you everyone. By the way, I use this code in Wordpress Page. ...
-1
votes
0answers
20 views

Capitalising module/function names? [on hold]

I have basic programming background in Python and am presently using pypath to analyse protein interaction networks. I am trying to understand the environment/module/function organisation, and have ...
0
votes
1answer
27 views

How to adjust function for Iterable Array?

I have a function called f, which looks like this: val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") implicit val localDateOrdering: Ordering[LocalDate] = Ordering.by(_.toEpochDay) def f(v: ...
0
votes
1answer
30 views

name (?) is not defined

I'm beginner in Python programming using PyCharm trying to practice functions but it returns below error: name 'rflag' is not defined but I think its defined! here is the code: def searcher(...
0
votes
3answers
37 views

Why isn't this code working when i try to use IFFE

I tried to run this code. var temp = (function () { var a =10; return { function (a) { console.log('Value of a is ' + a); } } })(); temp(); I expect IIFE to return the function and ...
2
votes
1answer
24 views

How to get battery percentage from the browser using Javascript? [on hold]

I want to get my laptop's percentage of battery from OS or something. But I don't have any idea about how to get it. I use Javascript, CSS, Java and Python (Python is actually on a beginner's level). ...
0
votes
1answer
15 views

Object assignment in place of parameter in the constructor

In the class below, for the constructor the parameter used is { cabinet = 'spruce', distortion = '1', volume = '0' } = {} class GuitarAmp { constructor ({ cabinet = 'spruce', distortion = '1', ...
0
votes
2answers
28 views

Function to reduce outliers

I am working with support vector machines and want to reduce outliers. So I have a function to reduce outliers to 70% of there original value. I find this method better than winsorization as it doesn'...
0
votes
0answers
29 views

How to remove list items from a parent with vanilla JS using the remove method?

Warning: my javascript code looks messy. I still have to modularize it a bit more I am trying to remove list items from a parent node, which were once added by the addPhraseToDisplay function. The ...
1
vote
1answer
16 views

correctly specify parameter values when calling a function in JavaScript

I have a function foo defined as follows, foo = function(a=1,b=2,c=3){ console.log("your inputs are a:" +a+", b:"+b + ", c:"+c+".") } How do I use the default value of b and specify a and c only ...
1
vote
0answers
15 views

how to create function in Apache Pulsar for docker

Step 1: Copy Jar in container pulsar: docker cp name.jar {ID_CONTAINER}:/pulsar/name.jar Step 2: Create function in container pulsar : docker exec -it {ID_CONTAINER} bin/pulsar-admin functions ...
-1
votes
1answer
28 views

C++ function for vigenere cipher only sometimes working (works for some inputs, skips shifts for others)

For an in class assignment I had to write a function that puts a user input string through the vigenere cipher with the optional help from helper function. I was able to reach a partial solution using ...
0
votes
1answer
18 views

How to redefine JS function with regard to closure?

I try to redefine Class.method, it uses a function from a closure. Modified version I provided currently is not working as it uses e() function which is not directly accessible from Global namespace. ...
1
vote
1answer
17 views

Creating a function to calculate slope m=(y2-y1)/(x2-x1) in R

I am a new student to programming of any kind and am having trouble creating a function to calculate slope in R. What do these errors mean that are preventing the function from working? slope <- ...
0
votes
1answer
19 views

How to include a python function in the source of html iframe?

how i put a function from python file to the iframe source of html file ? html file: <iframe src='http://192.168.1.100/' id="gallery" class="iframe" name='gallery' width="100%" height="100%" ...
1
vote
1answer
49 views

I need to compose functions with different signatures

In scala I have two functions with different signatures. I would like to write a function that composes the two functions into a new function with a common signatures. type CFunc = (Context)=>...
0
votes
0answers
23 views

passing a parameter in a function, the second parameter is always null [duplicate]

Function SCP-ImplementationFiles($selectedDirectory, $fileName) { Write-Host $rdfFile.GetType() $rdfFile.Name SCP-ImplementationFiles($directoryPrompt, $rdfFile.Name) My Write-Host is ...
0
votes
1answer
24 views

Adding javascript to wordpress functions.php

JavaScript(s) Are Not Loading I found this really awesome static html/css template online and wanted to convert it to a wordpress theme but after the conversion i noticed the html/css is loading from ...
1
vote
1answer
30 views

Passing selected arguments from a dictionary to a function

Given a set of functions that differ in their signatures and a dictionary that contains (key, value) pairs for each of the required arguments, I want to find an elegant way of passing the dictionary ...
0
votes
1answer
20 views

Cursor position in textarea on click

I am working on a little emoji function. My problem is when I have a text in the textarea and select an emoji from the drop down it always goes to the end of the text even if I place the cursor at the ...
1
vote
2answers
43 views

Equality of Function Designators

Are two Common Lisp function objects with the same symbol designator always eq? For example, this comparison seems to work: (defun foo (fn) (let ((ht (make-hash-table))) (eq (symbol-function (...
0
votes
3answers
26 views

How can I use a text value as a mathematical operator?

I am trying to build a simple calculator where the user inputs 2 positive numbers and a calculation symbol (+,-,*,/) and on keyup a jQuery script is called to calculate the result and print it out. ...
3
votes
1answer
57 views

Partitioning a String into more pieces with separating char in Haskell

I have the following homework: Define a function split :: Char -> String -> [String] that splits a string, which consists of substrings separated by a separator, into a list of strings. Examples: ...
0
votes
0answers
4 views

Insert fails on partitioned table for Postgres 9.6

I have a huge table that we need to get partitioned monthly. This table is currently child of another table. I am trying to create a partition on this table and those partitions are going to be ...
0
votes
1answer
31 views

using function in node js

a) Write an integer function Input as follows: function Input(s) The function takes in a String parameter that will be used as part of the input prompt, e.g. "Please enter 1st integer" ...
-1
votes
2answers
23 views

i can not seem to get it exactly, i am getting the factorials but cant seem to find a way to put in the combination formula

i have written the code but am not able to get the formula of combination to go in, i am very new to this and use these extra excercises to help with math, can you help what to improve or how to ...
0
votes
0answers
25 views

How to fix <filter object at xxxxxxx> error in Pyton 3.x? [duplicate]

Filter function not yielding the expected result!! See code shared below.. I am running on Python 3.x # We take cube of all numbers using map() cubes = map(lambda x: x**3, range(10)) print(list(...
0
votes
1answer
22 views

filtering out specific derivatives

I have generated several functions. find_derivative simply takes the derivative of several terms using the product rule and makes a new equation. So if i input 3x^2 + 2x^3 I get 6x + 6x^2 in the ...
0
votes
0answers
27 views

SDL function to minimize borderless window from taskbar

I've searched the whole internet and I found functions used in SDL v1 and didnt find any answer for SDL2. I want to minimize my borderless window by clicking in taskbar because if I click it right ...
1
vote
1answer
42 views

When I return a variable from a function its not showing all of it?

I have a function that retrieves a subnet from an Excel sheet (e.g. 10.123.123.64/26). I then trim the ".64/26" characters from the end and return it. When I recall the variable outside the function ...
0
votes
1answer
24 views

Filtering out specific terms

I have written a function that uses derivative product rule to find derivative of a term: def find_term_derivative(term): x , y = term new_term = (y*x, y-1) return new_term def ...
0
votes
1answer
29 views

I want to call var from another handler function

I am doing a project where i need to call a variable from another function and i dont know how to call it here is the code I want to call team1,team2,server from HelloWorldIntentHandler how do i call? ...
1
vote
2answers
31 views

How to solve incorrect return value of javascript+firebase function due to order of operation is different when retrieving data?

I am currently implementing a javascript function to judge if user id and name matches or not. function name_match(user_id, user_realname) { var dbref = firebase.database().ref(); var ...
0
votes
2answers
43 views

How do I pass all key value pairs of a dictionary one after another in function of a class?

I have the following `Restaurant class that accepts an arbitrary number of arguments and keyword arguments. class Restaurant: def __init__(self, name, location, *foods, **pizza_toppings): ...
0
votes
0answers
28 views

Can someone explain this javascript code about higher order functions? [duplicate]

I am a JavaScript noob. I came across this code for higher order functions recently. Can't figure out why the function is returning itself or why the brackets '()' at the end is necessary. const ...