Questions tagged [function]

25753 questions
0

votes
0

answer
23

Views

Function always return true in prod mode

i'm building an app to make people book on some courses. I have an array in my component: public corsiSelezionati: {nome: string, sede:string, codice:string}[] I have an onChange() func that gets triggered every time a form has a change: onChange($event) { try { const nome = ($event.target.options[$...
Francesco Buccoliero
0

votes
3

answer
17

Views

Php Static Class and Normal Class

$export = db::get($data); foreach ($export as $user) { // } echo "Totol User: " . $export->count(); Hello, I have a problem. I'm pulling array() with db::get($data). Then I want to show the total number of records with a function such as $export->count(). Is there an example suitable for this struct...
Huseyin Yilmaz
1

votes
2

answer
28

Views

Pulling out a dictionary field to use as a function name

I am attempting to create functions using a for loop, by referencing a dictionary. My two different attempts have been unsuccessful: dictionary = {1:'Apples', 2:'Pears', 3:'Carrots'} for i in range(1, 4, 1): name = dictionary[i] def name(price, quantity): total = price*quantity return total print(Ap...
Matt
4

votes
5

answer
162

Views

Using OR logic on an array as argument in Sumproduct

I'm having a fairly large dataset where I need to combine multiple entries into a single value. My dataset contains data on the combination of two datasets, each using their own ID's and keys. I thought of using a Sumproduct() function like this: =SUMPRODUCT(--('Raw data'!C:C=Landgebruik!A2);--('Raw...
Luuklag
1

votes
2

answer
2.2k

Views

How to use Function VB.NET Insert To Database?

i using function with vb.net. i'm query sql to datagridview and insert data from datagridview to Databse By function. But Error in function: The name 'EXHBK13004' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. i wa...
nettoon493
1

votes
3

answer
86

Views

Assign and execute Javascript function simultaneously

Is there a more elegant way of writing something like this, where myFunction is asigned to the function func but func is also executed during the assignment? var myFunction = (function(){ var func = function(){ console.log('hello world'); }; func(); return func; })(); ... myFunction();
danbroooks
1

votes
1

answer
586

Views

Exiting a function with trap and its error code

Let's assume I have the following function: #!/usr/bin/env bash f(){ trap 'printf "\nAborting\n"; return 1' SIGINT sleep 10 return 0 } If I run f and wait those 10 seconds and then do $ echo $? > 0 That's expected. But if I run f and hit Ctrl+c, the function f is aborted, but $ echo $? > 0 instead o...
pfnuesel
1

votes
3

answer
94

Views

My c++ function is destroying variables when it shouldn't be

The purpose of this function is to take a struct, and enlarge the array by 1. It does this by copying the array to a temporary array, deleting and recreating the original with a larger size. My problem is that when I run the function, all of my values within the struct become '-17891602'. Correct me...
1

votes
1

answer
488

Views

jQuery function as a string with arguments as Array (JavaScript “apply()” equivalent for jQuery elements)

I would like to call a jQuery function into a jQuery plugin, with its name as a string, and its arguments as an object (Array). I'm looking for a kind of equivalent to the JavaScript "apply" function in jQuery. I had to find a workaround, but it's really dirty and limited. Here it is : //funcName is...
Corentin
1

votes
2

answer
1.8k

Views

Node “ReferenceError: require is not defined” when executing a Function object

I'm trying to execute a Function object which is essentially the same as the following pseudo-code: var testF = new Function("x","y", "var http = require('http');"); testF('foo','bar'); And get: ReferenceError: require is not defined Do I need to somehow add something that reloads the require module...
Scott Graph
1

votes
1

answer
308

Views

How to sum two variables: constant and iterated in text input's “name”?

I have a function: jQuery(function($) { var scntDiv = $('#div'); var i = $('#div p').size() + 2; var x = ; var a = 0; $('#add').click (function() { $('Remove').appendTo(scntDiv); i++; a++; return false; }); $('#delete').live('click',function() { if( i > 2 ) { $(this).parents('p').remove(); i--; } re...
Daniel
1

votes
2

answer
791

Views

unordered_map hash function return

I'd like to have an unordered_map with a struct, that I'd like to use as the key, of multiple std::set< std::string >. I see that a custom hash function is required and that a string can have std::hash applied; however, I cannot determine what should be returned to satisfy the purpose of the hash fu...
1

votes
2

answer
12.8k

Views

How to use for to sum a range in google app script?

I want create a simple custom sum formula in google Spreadsheets using google app Script. function somaDias(range, days) { var sum = 0; for(i=0; i
user3347814
1

votes
2

answer
15

Views

JavaScript Destructive Map Function

I'm trying to make this map function a more destructive version of itself. Meaning the map function modifies the original array instead of a new one. function map (array, callback) { var result = [] for (var i = 0; i < array.length; i++) { result.push(callback(array[i])) } console.log("Array",array,...
Marc Wilk
1

votes
2

answer
513

Views

Understanding pre/post assembly code for a function call in x86 IA32 assembly

So we have the following code, setting up for a function call with its arguments, its main body omitted (etc etc etc), and then the popping at the end of the function. pushl %ebp movl %esp, %ebp pushl %ebx movl 8(%ebp), %ebx movl 12(%ebp), %ecx etc etc etc //end of function popl %ebx popl %ebp Here'...
Spag Guy
1

votes
3

answer
339

Views

R- reshape2 with aggregation min function

I need to transpose a df in R and the aggregtion function has to be min. Example: library(reshape2) N
GabyLP
1

votes
1

answer
185

Views

Swift functions

I am learning Swift and I got problem with understanding how functions work. Let's say I got a simple function: func sayHello() { println("hello there") } And I can assign this function to variable or constant in that way: var hello = sayHello So now variable hello is type of function which can be w...
pardnoj
1

votes
1

answer
8.2k

Views

Conditional formatting for cells when cell above has the same value

Is it possible to apply conditional formatting to a whole sheet such that whenever the cell above the current cell has the same value (either text or number) as the current cell, the current cell will be formatted yellow fill/blue font? For example, when cell: A1 is blank A2 AAA A3 AAA A4 AAA A5 i...
user3045580
1

votes
3

answer
632

Views

Why am I getting a “No matching subprogram was found.” error?

I wrote a function inside a package file, and I'm calling it inside the main vhd file. It seems to me everything is correctly in place. But the Sigasi editor says "No matching subprogram was found." at the line where I called the function. This is the package file content: LIBRARY IEEE; USE IEEE.STD...
Mehmet Salih Cüvelek
0

votes
2

answer
22

Views

How to use the function attribute as an attribute of the onclick event (input element)?

Let's say I have the code below: function addValue(x){ var button = document.createElement( "input" ); button.setAttribute("type", "submit"); button.setAttribute("src", "images/repeatStageIcon.png"); button.setAttribute("class", "option-image"); button.setAttribute("title", "Repeat Current Stag...
0

votes
1

answer
16

Views

How to find the maximum value of a random vector with a loop in R

I have created a 100 digit vector with random numbers and I have to find the minimum and maximum values in r without using min() or max() functions. I have to use conditional logic and comparison operators, so I managed to find this for the minimum: findMin
Seabass
0

votes
0

answer
16

Views

Weird behavior unused argument in function R

I implemented a function 'identify_case' i.e.: ## Function that identify the gaps of NAs according to their length identify_case = function(df, variable, seuil) { df$value = ifelse(is.na(df[,variable])==TRUE,1,0) df$temp = rep.int(rle(df$value)$lengths, rle(df$value)$lengths) df$gap = ifel...
Amandine.G
0

votes
3

answer
30

Views

lambda expression to assign a member function pointer

I need the syntax for a lambda expression that will return a pointer to a member function. For example I have class A: class A { int x; void (A::*SomeFunction)(); } I want to set SomeFunction to a lambda. I tried doing it like this: A a(); a.SomeFunction = [this](){ printf("Hello from lambada %d",t...
tomer zeitune
1

votes
1

answer
1k

Views

Cast a variable as a function/method pointer in Dart? (Delegate?)

Say I have a Map type that stores functions/methods inside of it, like so: Map triggerHandler = { 'x' : (t) => hello(t) }; Now, what I want to do next is to declare that the Type of these Map values are to be functions. I can always do this: Map triggerHandler = { 'x' : (t) => hello(t) }; But this...
willsquire
1

votes
1

answer
1.4k

Views

do parallel combine progress bar and process

I'm having issues to combine the process that I want to run in parallel and the creation of the progress bar. My code for the process is: pred_pnn
GabyLP
1

votes
1

answer
600

Views

Passing vectors and params from Python to R functions

I am learning Python and R and am having an issue passing parameters from Python to an R function named "Contours". The below works..... Python (testr.py) import rpy2.robjects as robjects robjects.r(''' source('Wrapper.R') ''') r_myfunc = robjects.globalenv['Contours'] r_myfunc() R (Wrapper.R) sour...
Jane WIlkie
1

votes
2

answer
1.3k

Views

A bijective function from N*N*N to N

Can anyone help me in finding a bijective mathematical function from N * N * N → N that takes three parameters x, y, and z and returns a number n? I would like to know the function f and its inverse f' in a way that if I have n I will be able to determine x, y, z by applying f'(n).
Ramzi Zelfani
1

votes
1

answer
290

Views

C++ function that takes args Eigen sparse matrices

Eigen library provides/suggests numerous ways to pass a dense matrix in a function, so that it works for a different types that share the same base, and avoids copying (i.e. Ref, template expressions). However, I haven't found anything equivalent for sparse matrices in either eigen documentation or...
Georgios Georgiou
1

votes
2

answer
2k

Views

Parse function inside Json

I have this JSON as a result of the function JSON.stringify(): {"get":"function (f,g){'use strict';var h,i;if(i={},'string'==typeof f){if('object'==typeof g)for(h in g)i[h]=g[h];i.url=f}else if('object'==typeof f)for(h in f)i[h]=f[h];return i.type=i.type||d,i.oauthio={provider:a,tokens:b,request:c},...
Claudio Loseto
1

votes
4

answer
82

Views

Random() method keeps changing final String in Java

I'm trying to create a rock paper scissors game and teach myself more about subroutines in Java. To check whether the logic behind it is right, I wrote in two parts in the program where the current hand position of the opposing player is checked. However, it's different every time, even though I as...
Snupas
1

votes
1

answer
692

Views

JQuery function not firing on enter keypress

I have the following jQuery/js controlling a trello style input field. So when you click on the span element, it switches to an input field. Then after you finish editing the element and take focus away from it(blur), it switches back to the span element with the new text. I also having it submittin...
Zachary Bell
1

votes
2

answer
819

Views

Execute Returning None with PostgreSQL in Python

Here is my code conn_string = "dbname=detector user=postgres password=1234 host=localhost port=5432" print "Connecting to database\n ->%s" % (conn_string) # get a connection, if a connect cannot be made an exception will be raised here conn = psycopg2.connect(conn_string) which it is outputt...
1

votes
2

answer
2.3k

Views

How do I implement a filter in PowerShell?

I'm trying to figure out a way to incorporate a filter into a custom function and I haven't been able to get it working: Function Test-Me{ Param ( $Filter = "Number -like ""Three""" ) $Obj = New-Object PSObject -Properties &{ Number = "One","Two","Three" } If($Filter){ $Obj | Where-Object $Filter }e...
Colyn1337
1

votes
1

answer
3k

Views

Concatenating distinct column values in SQL Server

I am trying to concatenate many columns and separating it with a comma as below: Column ------ abc bcd bgd abc Expected output: abc,bcd,bgd I am using this code: CREATE FUNCTION concatinate(@PK uniqueidentifier) RETURNS varchar(max) AS BEGIN DECLARE @result varchar(max) SELECT @result = ISNULL(@res...
Gerald Baretto
2

votes
2

answer
46

Views

Why can I declare a javascript var multiple times? [duplicate]

This question already has an answer here: Declaring a Javascript variable twice in same scope - Is it an issue? 3 answers Why am I able to declare a var multiple times? I would expect an error. This code raises an error: let a = true; let a = false; Uncaught SyntaxError: Identifier 'a' has alread...
user332336
0

votes
1

answer
16

Views

Creating a function for plotting using ggplot2 and providing data frame, x, and y for the function. How to reference the axis the right way? [duplicate]

This question already has an answer here: Passing arguments to ggplot in a wrapper 2 answers R pass variable column indices to ggplot2 [duplicate] 1 answer How to use a variable to specify column name in ggplot 3 answers I want to create a function for plotting using ggplot2 because I will have t...
Ben
1

votes
2

answer
771

Views

Swift 3.0 range as function parameter

I'm making a function to get the specific days that falls on specific weekdays Ex. Sundays in 9.2016 = 4,11,18,25 import UIKit var daysOff = [Int]() func getNumberOfDaysInMonth (_ month : Int , _ Year : Int ,lookingFor : Int) -> (firstDay: Int , daysResults: [Int]) { var day = Int() if lookingFor >...
Nitrousjp
0

votes
0

answer
5

Views

How to 'Change value in function outside function'?

I need change value in function after function is called. But i don't know how. I don't want re call function because it's maked me more problem and not use meta. Example: I call 'a(value)' function , and later i call 'b(newvalue)'. 'b' function change value in 'a' function. 'a' function called only...
Gigabait
1

votes
1

answer
1.7k

Views

Procedure with assumed-shape dummy argument must have an explicit interface [duplicate]

This question already has an answer here: Module calling an external procedure with implicit interface 1 answer I am completely new to Fortran 90 and I am trying to understand how to pass an array to a function. I looked on the web and I could not find any clear and simple enough example, so I deci...
valerio
1

votes
1

answer
1.9k

Views

Alternative for append()

For the below add method: def __add__(self, other): self.str_list.append(other) self.count += 1 return self.str_list How may I rewrite this without append? PS: 1) str_list is an instance variable of type list declared in init 2) No inbuilt functions to be used.
J T

View additional questions