FAQ Database Discussion Community


What is fn.bind.apply(fn, arguments) doing?

javascript,arguments
I saw this shortcut given as an answer on a code Kata but I am having difficulty understanding exactly what the below example is doing. function func(fn) { return fn.bind.apply(fn, arguments); } So far my understanding is that bind creates a new function similar to doing the following: function func(fn)...

Passing list as an argument in wolfram mathematica

list,arguments,wolfram-mathematica
I have a problem. I need to calculate the mean, but I don't understand why the code below doesn't work. I read the documention and this function should accept a list and return the mean value. What am I doing wrong? Why can't I pass a list to a function...

In Ruby, how do I invoke system with an array, without eval?

ruby,arrays,arguments
I want to build up a command as an array of strings, and the invoke it through system, but I don't want to invoke the shell. # I want this to echo '*' f=['echo', '*'] system(f) If I join the array with spaces, I get a shell expansion, so that's...

JavaScript: Variable undefined inside if else

javascript,function,redirect,if-statement,arguments
Here I have a simple countdown function that redirects the user after 5 seconds. <script type="text/javascript"> var timer = 5; var counter = document.getElementById("countdown"); function countdown(target) { counter.innerHTML = timer--; if (timer >= 0) { setTimeout(function () { countdown(); }, 1000); } else { // Redirect the user console.log(target); //...

Simple program leads to seg fault when opening a file

c,file,printing,segmentation-fault,arguments
I've got a text file that contains a bunch of strings, nothing important in terms of my problem. The code here compiles/runs, and If I type in the correct text file, the first if statement runs. However, if I don't the else statement doesn't execute, but instead I get a...

finding the correct Function arguments

python,function,python-3.x,arguments
I keep getting an error telling me that members needs an argument: import random def club_members(members): members=int(input("members")) print ("The winner is", + (random.randint(1, members))+ "congratulations") club_members() Error msg is: Traceback (most recent call last): File "C:\Users\chris\Desktop\Python_Stuff\hockey 1.py", line 7, in club_members() TypeError: club_members() missing 1 required positional argument: 'members' ...

Derive a class name from another class name in template

c++,templates,arguments,class-names
In order to use a library, I need to use different classes that have the same base name. I.e. MyClass MyClassImpl PreMyClass And so on. in order to use them with template I need pass all these class names. template <typename T, typename TImpl, typename PreT> class ClassThatUsesAllTheseObjects { public:...

wrong number of template arguments (3, should be 4)

c++,templates,properties,arguments,getter-setter
I tried to use property on c++ to use it instead of too many setter and getter function in data class have lots of member variable. there are two property class. first one has fixed setter and getter function by default set, get. second one support using custom setter and...

checking arguments in a shell script

shell,if-statement,arguments
I'm having a surprising large amount of trouble finding a guide on this. what's wrong with this shell script: if ["$1" == "-t"] then echo "t" elif ["$1" == "-r"] then echo "r" fi It's supposed to be a very simple test. if the argument is -t, do one thing,...

Python - for fi in sys.argv[1:]: argument list too long

python,bash,arguments,argv
I am trying to execute a python script on all text files in a folder: for fi in sys.argv[1:]: And I get the following error -bash: /usr/bin/python: Argument list too long The way I call this Python function is the following: python functionName.py *.txt The folder has around 9000 files....

Drupal - Custom page with arguments

php,templates,drupal,drupal-7,arguments
I am looking to hook every URL that starts with /questions to one template file. So for example: /questions /questions/question1 /questions/question1/respond /questions/question1/somethingelse all of the above should go to my template questions.tpl.php Then within my questions.tpl.php I want to do stuff with the arguments. Is there a way to do...

ES6 destructuring function parameter - naming root object

javascript,function,arguments,ecmascript-6,destructuring
Is there a way to retain the name of a destructured function argument? I.e., the name of the root object? In ES5, I might do this (using inheritance as a metaphor to make the point): // ES5: var setupParentClass5 = function(options) { textEditor.setup(options.rows, options.columns); }; var setupChildClass5 = function(options) {...

Practical Reasons to use C# “named arguments”

c#,methods,parameters,arguments,optional-parameters
I find this feature "named arguments" from C# to be really weird because I see two flaws from it. The book says "named arguments give you the "ability to pass arguments in any order". Two flaws I think is a problem for this C# feature: It violates "information hiding" in...

Bash, print 0 in terminal each time a non recognised argument is input

linux,bash,arguments
I have a bash program which extracts marks from a file that looks like this: Jack ex1=5 ex2=3 quiz1=9 quiz2=10 exam=50 I want the code to execute such that when I input into terminal: ./program -ex1 -ex2 -ex3 Jack does not have an ex3 in his data, so an output...

Matching vector of default values using match.arg() with or without error [R]

r,function,arguments,match,evaluation
I want to write a function that applies one of two different statistical methods to its input. In the process, I noticed some behavior of different functions that I do not understand. The function I want to write should have the following properties: it should have a vector as a...

How do I identify the last variable argument? [duplicate]

c++,char,arguments,printf,va-arg
This question already has an answer here: Count number of parameters in C variable argument method call 3 answers So in my function I want to take a variable number of char pointers. void myFunction(char *_Name, ...); Only, when I iterate through the arguments my code breaks because I'm...

I am trying to solve a PHP exercise but am unable to understand what's happening

php,arguments,globals
First of all I'm very sorry for my irrelevant question title, as I did not know how to write it better. To start with, I am a PHP beginner. I am solving some PHP exercise and I came upon a question I don't know where to start with: function q3()...

Syntax error calling method with argument

objective-c,methods,arguments
I am trying to call a method that takes an argument and do not have syntax right. Can someone see what I am doing wrong? The precise error is "Use of Undeclared Identifier 'self'". - (NSString*)uniquePicName:(NSString *)extensionString { // Extension string is like @".png" NSDate *time = [NSDate date]; NSDateFormatter*...

Use << operator inside function arguments

c++,arguments,stringstream
I want to create a function that allows me to use the << operator in argument and inside it uses the corresponding stringstream. Something like: /* This does not do what i want below */ void printStream(std::stringstream& ss) { std::cout << ss.str(); } /* Desired function usage */ printStream("The number...

Flash AS3 Crashing After A Multiple Clicks - Argument Error - noSource error

actionscript-3,flash,arguments,kiosk
I have here, some AS3 that is used to create a 19 button interactive kiosk. It calls 20 different video_files to be played in an FLVPLayer. When one button is clicked, it draws the player and specifies the source. Whats happening is on our PC, is our crazy-kid-test, where we...

Reading a table when function has many argument return an error

c++,arrays,lua,arguments,lua-table
I'm trying to read an array inside a Lua function in a library that I'm developing. When I call the function with one argument, like xyz = {3, 4, 5} setxyz(xyz) I read the array correctly, while if I add a second argument xyz = {3, 4, 5} setxyz(xyz, 3)...

Pass n arguments to a third party function (python)

python,arguments,third-party
I am using a software named iraf, and I have to pass n arguments to a function, something like: iraf.scombine(input=data[0]+'[1,2,3],'+data[1]+'[1,2,3],'+data[2]+'[1,2,3]',output='tmp') where data[0], data[1], data[2], data[3], ... are file names, so that filename[1,2,3] is a value Is there a way to do that for n arguments, something like iraf.scombine(input=(data[i]+'[1,2,3]' for i...

JavaScript - If a function is passed as an argument, can it be returned as a string before the function is evaluated?

javascript,function,arguments,argument-passing
Consider the following code: function add(a,b) { return a + b; } function displayFunction(func) { console.log(_WHAT_SHOULD_GO_HERE_); // I want to log 'func' to the console } displayFunction(add(2,3)); // I want this to log "add(2,3)" Is this even possible to do in JavaScript?...

how to initialize a parameter in javascript function when i define the function

javascript,parameters,initialization,arguments
i have a defined a function with a parameter in javascript, and i don't know how to initialize it's parameter, any one help me. the code is bellow <br/>Enter a number: <input type="text" id="txt1" name="text1"> <p>Click the button to see the result</p> <button onclick="myFunction(5)">show result</button> <br/> <p id="demo"></p> <script> function...

Can I pass text file as an argument in a main function in C?

c,arguments
I am wondering if I could pass file as an argument in a main function? I mean not a name of the file but file itself.

When are variables evaluated when passing them into functions?

javascript,function,variables,arguments
This is probably a simple question, but I would really like to know the answer. Are the arguments passed into a function calculated once and set as local variables or are they calculated every time they're used inside the function? For example: When you write a forLoop, you should set...

Dynamic arguments for Python functions [duplicate]

python,arguments
This question already has an answer here: Expanding tuples into arguments 3 answers I have a list of lists, and I would like to enter them into a function in such a way that each element of the main list is a different argument to the function. squares =...

In R: pass column name as argument and use it in function with dplyr::mutate() and lazyeval::interp()

r,function,arguments,dplyr,variable-names
This question links to this SO answer except that here I want to use the variable specified as function arg in a mutate_(). It works if I don't make any "calculations" in the mutate_(): data <- data.frame(v1=c(1,2), v2=c(3,4)) func1 <- function(df, varname){ res <- df %>% mutate_(v3=varname) return(res) } func1(data,...

Why does respond_to? need symbols as arguments in Ruby?

ruby,arguments,symbols
Why does this method only accept symbols and not strings as its arguments? x = 10 x.respond_to?(next) Pushing a string like the above would throw (ruby):1: void value expression....

Python argparse doesn't show up help message correctly

python,arguments,argparse
I have to parse arguments where 4 of them have to be tied with each other, and last 2 have to be exclusive group 1 sub_exclusive_1 has 4 arguments where all of them must be defined if any of them have been defined. group 2 sub_exclusive_2 has 2 arguments where...

Generic argument list

c#,list,generics,arguments
I have a method that has a generic argument and the code is as shown below : public Result[] Compare(PropertyInfo property, T previous, T current) { var type = previous.GetType().GetGenericArguments()[0]; var listType = typeof(List<>); var constructedListType = listType.MakeGenericType(type); var instance = (IList)Activator.CreateInstance(constructedListType); instance = previous //throws compile error obviously, }...

Extract the arguments of a function to the global scope (javaScript)

javascript,function,arguments
I was just wondering if there was a way to extract the arguments of a function x(...){...} to the global scope and maybe store them into a variable. I know that if you construct a function, you can return the "arguments" object, but that is not what I want because...

Is there a way to pass auto as an argument in C++?

c++,function,arguments,auto
Is there a way to pass auto as an argument to another function? int function(auto data) { //DOES something } ...

R function with functions as arguments, each with variable arguments

r,function,arguments,simulation,quantile
In answer to a question on Cross Validated, I wrote a simple function that used arbitrary quantile functions as its arguments etacor=function(rho=0,nsim=1e4,fx=qnorm,fy=qnorm){ #generate a bivariate correlated normal sample x1=rnorm(nsim);x2=rnorm(nsim) if (length(rho)==1){ y=pnorm(cbind(x1,rho*x1+sqrt((1-rho^2))*x2)) return(cor(fx(y[,1]),fy(y[,2]))) } coeur=rho rho2=sqrt(1-rho^2) for (t in 1:length(rho)){ y=pnorm(cbind(x1,rho[t]*x1+rho2[t]*x2)) coeur[t]=cor(fx(y[,1]),fy(y[,2]))} return(coeur) } However, both fx and fy may...

Filtering directive in Angular.js

javascript,angularjs,function,arguments
I'm trying to develop a single web application which is a blog, displaying posts. They are included in a template by the ng-repeat directive: <div class="post" data-ng-repeat="post in postList "> <div class="date">published: {{post.published_at | date:'dd-MM-yyyy, HH:mm'}}</div> <a class="btn btn-default" data-ng-click="editPost(post)"><span class="glyphicon glyphicon-pencil"></span></a> <a class="btn btn-default" data-ng-click="deletePost(post)"><span class="glyphicon...

Common Lisp - Giving &rest Lists as Arguments

arguments,lisp,common-lisp,sbcl
As a result of musings around an exercism problem, I am trying to write a function that takes an input number and an arbitrary length list of divisors to test, along with the expected divisibility (i.e. remainder 0) as a boolean, returning true if all expectations are met (defaulting to...

invalid arguments passed to implode

php,arguments,comma,implode
I am fetching some set of ids from database and want to print them comma separated using php implode() method. But it is giving me a warning that I passed invalid arguments to implode. So why do I get this warning and how can I fix my code, to get...

passing wildcard arguments from bash into python

python,bash,scripting,arguments
I'm trying to practice with python script by writing a simple script that would take a large series of files named A_B and write them to the location B\A. The way I was passing the arguments into the file was python script.py * and my program looks like from sys...

Ruby passing multiple parameters in methods [duplicate]

ruby,parameters,arguments
This question already has an answer here: Optional argument after splat argument 6 answers Actually i am trying to use third parameter as method as get and second parameter as *p but it throws error def ss(a,*b,method="GET") puts a end ss("fff",98,"POST") The above code throws error li.rb:1: syntax error,...

What is correct way to use string as an argument and parameter or return type in C++

c++,string,arguments
In this Code a method name setname(). In this method I am using parameter (Char *aname), argument "Name_Student" (When calling). But getting error: "deprecated conversion from string constant to 'char*' [-Wwrite-strings]" #include <iostream> #include <string> using namespace std; class student { int rollno; char *name; public: void setname( char *aname);...

does size of argument in a javascript function affects its performance?

javascript,function,arguments,subsetting
I have a key value pair containing five keys with values as huge array of thousand objects each . I can either subset it while passing it into a function or i can pass whole array in the function. For e.g: keyVal ={"first_array": Object[1000], "second_array": Object[1000], "third_array": Object[1000], "fourth_array": Object[1000]...

Python class argument error

python,function,class,arguments
I am creating a menu but i have come across an error an would like some help as i don't know what is wrong or how to fix it, the piece of code says i am putting an argument in but i have not entered an argument. class menu(object): def...

Nodejs process.argv[2] is omitting data after space even with \ when run through bash script

node.js,bash,arguments
So I have a node script that takes an argument, if I run the node script alone then something like game\ of\ thrones the entire string is considered process.argv[2] which is what I wanted and expected, the problem is when I run a very small bash script called add which...

variables in system() call C++

c++,arguments,system
I have a variable in argv[1] which I need to call inside another c++ file in such a way: system("./assemblerL.out", argv[1]); this above is incorrect syntax as I am getting "too many arguments" errors. What is the correct way of doing this?...

ORA-00939: too many arguments for function in CASE Statement

sql,oracle,syntax,arguments,substr
I'm getting the ORA-00939: too many arguments for function error from my case statement. I have tried splitting it up into multiple CASE statements but still get the same error. CASE WHEN l.fridge_door_modela_id = 'II-SH' THEN 'IW' WHEN l.fridge_door_modela_id = 'IIC-SH' THEN 'IW' WHEN l.fridge_door_modela_id = 'CD' THEN 'RPFX' WHEN...

Display QMessageBox with multiple arguments

c++,qt,arguments,qstring,qmessagebox
I'm using the Qt framework and I'm a little rusty with it. I have two QStrings first and last I want to display them in a QMessageBox but don't know how to include multiple arguments. This is what I have to code it with on argument: QMessageBox::information(0, "Full Name", QString("%1...

Passing arguments to a perl package while using it

perl,documentation,arguments,standards,packages
it is possible to pass some arguments while using a package, for example: use Test::More tests => 21; I wasn't able to find any valuable documentation about this featue. Are there any pros and cons of passing such arguments? Best, R....

What do we call the argument (variable or its value) of a function in Javascript?

javascript,function,arguments,argument-passing
OK lets take an example: function student(name,age){ document.write("I am " + name + "and I am " + age + " years old." ); } var student_name = "Divyansh"; var student_age = 17; student(student_name,student_age); // now my question is what do we call the arguments of the function student :...

How do you read an argument into an array

arrays,perl,command-line,passwords,arguments
I am not sure how to send the contents of an argument to an array. Say $ARGV[1] is a csv file. I want to read the contents of that file into an array in a perl script. This is what I have tried #!/usr/bin/perl use strict; use warnings; @array =...

Use of Guard.Against in a function that take a stream as input

c#,function,stream,arguments,illegalargumentexception
You write a method that takes a stream as input: public static class ClassA { public static void FunctionA(Stream stream) { Guard.Against(stream == null, "stream is null"); 1. Guard.Against(stream.position != 0, "stream position is not 0"); 2. stream.position = 0 3. //nothing //do stuff } } Should you Guard against...

How to use `--foo 1 --foo 2` style arguments with Python argparse?

python,arguments,argparse
nargs='+' doesn't work the way I expected: >>> import argparse >>> parser = argparse.ArgumentParser() >>> parser.add_argument("--name", dest='names', nargs='+') _StoreAction(option_strings=['--name'], dest='names', nargs='+', const=None, default=None, type=None, choices=None, help=None, metavar=None) >>> parser.parse_args('--name foo --name bar'.split()) Namespace(names=['bar']) I can "fix" this by using --name foo bar, but that's unlike other tools I've used, and...

C++ constructor prototype parameter

c++,class,constructor,arguments,prototype
For example, there is a class foo : class foo { public: foo (int = 10); ..... } The prototype of the constructor has "int = 10" inside. So, what does it mean? Int is just an integer type, isn't? So, isn't that illegal to assign a value to it?...

BASH: testing the number of arguments passed in an IF statement

bash,if-statement,arguments
i'm trying to send two arguments to .run file. $2 default should be 0. if $2 arg = 1 then grep -i a -1 --color -E $1 *.* else grep -i --color -E $1 *.* , something like this if [${2:-0} = 1] then grep -i a -1 --color -E...

How can a function return its name and arguments in R

r,function,arguments
Is there any way to get the name and arguments of a function from within itself. For example: > MYFN = function(name='test', num = 5, abool=T){ + return ("MYFN = function(name='test', num = 5, abool=T)") + } > > MYFN() [1] "MYFN = function(name='test', num = 5, abool=T)" I want...

passing arrays to a function in erlang

arrays,function,erlang,arguments
I am new to erlang programming and as a matter of fact no very experienced programmer. I need to pass an array to a function and then manipulate it.. however I have so far not be this what I found. module(easy). export([myfunction/1]). myfunction([myarray]) -> %% mycode.. hier I will need...

Javascript arguments shifting

javascript,arguments
Let's assume that we have the following function: var a = function(data, type){ var shift = [].shift; shift.call(arguments); shift.call(arguments); shift.call(arguments); shift.call(arguments); console.log(data); } a(1,'test', 2, 3); I understand that data and type are just references to specific values in arguments. But why in the end, data is equal to 3?...

Python command line arguments linux

python,linux,command-line,terminal,arguments
I have this little program(I know there is a lot of errors): #!/usr/bin/python import os.path import sys filearg = sys.argv[0] if (filearg == ""): filearg = input("") else: if (os.path.isfile(filearg)): print "File exist" else: print"No file" print filearg print "wasn't found" If i start it by typing python file.py testfile.txt...

C++ Type Check in Functions ignored (required double, provided int)

c++,function,arguments
I have the following code #include <iostream> using namespace std; int dmult(int a, int b){ return 2*a*b; } int main(void) { double a = 3.3; double b = 2; int c = dmult(a,b); cout << c << endl; return 0; } It compiles with MinGW without problems. The result is...

R: pass a vector of symbols into a function instead of a long argument list

r,arguments,symbols
I'm writing an R package that calls C code with the .C() function. I need to pass over 50 arguments into .C(), which seriously bloats my code and is prone to error. Rather than type output <- .C("my_dynlib", arg2, arg3, arg4, arg5, arg6, ..., arg53) I would rather have a...

'verbose' argument in scikit-learn

python,arguments,scikit-learn,verbosity,verbose
Many scikit-learn functions have a verbose argument that, according to their documentation, "[c]ontrols the verbosity: the higher, the more messages" (e.g., GridSearchCV). Unfortunately, no guidance is provided on which integers are allowed (e.g., can a user set verbosity to 100?) and what level of verbosity corresponds to which integers. I...

Segmentation fault with variable function arguments

c,variables,segmentation-fault,arguments
My program compiles without error, but when I run it, it quits with a segmentation fault after I input a value such a radius. I have it constructed to take a variable amount of arguments, but I suspect it could be something to do with the way I call each...

Perl argument “user” isn't numeric in array element

arrays,perl,arguments,warnings,numeric
I always get the message that my argument in array isn't nummeric. It happens 5 times in this little code: my $mcnamequery = "SELECT mcID FROM tblMCName WHERE mcName = '".$mcname."'"; $mcid = dbSelect($mcnamequery); print $mcid->{mcID} . "\n"; my $userfsquery = "SELECT userFS FROM tblMcSubs WHERE mcFS = '".$mcid->{mcID}."'"; my...

Pass various objects to a Class

android,class,arguments
I'm programming a layout in Android and it is quite dynamic. Since I'm also working with databases, I decided to split it into various classes, meaning that I have several "set up" classes. This, though, leads me to pass almost all layout elements to the classes when calling them. What...

Why do some methods accept only blocks as arguments in Ruby? [closed]

ruby,arguments
Methods like maps and collect only accept blocks. If blocks are not objects and can't be saved to variables, then why do these methods need them as arguments? multiples_of_2 = Proc.new do |x| x % 2 == 0 end sq = Proc.new { |x| x ** 2 } (1..50).to_a.select(&multiples_of_2) #...

What are some use cases of “$*” in bash?

bash,parameters,arguments,command-line-arguments
From the bash man page: "$*" is equivalent to "$1c$2c...", where c is the first character of the value of the IFS variable. "[email protected]" is equivalent to "$1" "$2" ... Any example where "[email protected]" cannot work in place of "$*"?...

Identify the arguments, parameters, local variables and global variables used in the following code?

javascript,parameters,arguments,global-variables,local-variables
The code is: var x = 32; var y = 44; var radius = 5; var centerX = 0; var centerY = 0; var width = 600; var height = 400; function setup(width, height) { centerX = width/2; centerY = height/2; } function computeDistance(x1, y1, x2, y2) { var dx...

Multiple parameters of a function

function,haskell,parameters,arguments,fold
How to give break (== ' ') xxs multiple boolean parameters without changing the definition? Or that is inevitable. For instance break (== (' ' || '\t' || '\n')) xss foldl and foldr are one way, but here they are not applicable, or at least I haven't been able to...

JavaScript function arguments: positional -> map transition

javascript,function,dictionary,syntax,arguments
I'm looking for a vanilla JavaScript solution. Say I've got a function with the following header: generateEmail(firstName, lastname, provider) I need to run it like this: generateEmail("John","Smith","gmail.com"); I would like to be able to call it with argument map instead of positional arguments, i.e. generateEmail({ "firstName":"John", "lastname": "Smith", "provider": "gmail.com"...

Are there any pitfalls to using Any vs specific argument type?

scala,types,arguments
Suppose I want a method to output something, a string or integer in this case. I can do it like this: def outString(str: String) { str // or "return str" } and run it like this: outString("foo") But I can also avoid initializing a specific type as an argument and...

How to return double[] in jni input argument

java,c++,arrays,jni,arguments
In my Java code I have defined the following function signature: public native boolean getData( double [] data ); In my C++ code I'd like to populate the double array data to return back to Java, and the returned boolean from the function will indicate whether the data was set...

Perl subroutine arguments like a hash

perl,parameters,arguments
How can I create a subroutine that can parse arguments like this: &mySub(arg1 => 'value1', arg2 => 'value2' ...); sub mySub() { # what do I need to do here to parse these arguments? # no arguments are required } ...

Passing MyClass defined in header as function argument to other file

c++,function,header,arguments
I've spent around an hour and couldn't find anything helpful on the Web. The problem is that I've got some files like a.h, b.h, a.cpp, b.cpp and main.cpp. In a.h I've got declared a container with attributes defined by myself. I would like to pass this container as and argument...

Two different arguments for the same function but return different results?

c,function,arguments
I have made a function that convert format of latitude and longitude from Degrees Minutes.m to Decimal Degrees. For example: latitude = 3130.1245 (Degrees Minutes.m) == 31.502075 (Decimal Degrees) The problem is that I call this function twice with the same argument but it returns two different results. How is...

Passing multiple arguments to curried functions

javascript,function,arguments,closures,currying
I'm currently reading the book, Effective Javascript and have reached the chapter regarding closures. There's an example that illustrates how to pass the argument of a nested function as so: function sandwichMaker(magicIngredient) { function make(filling) { return magicIngredient + " and " + filling; } return make; } var hamAnd...

Get argument from registry C#

c#,winforms,arguments,registry
I'm set key value in registry as follows- RegistryKey registryKey = Registry.CurrentUser.OpenSubKey ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); registryKey.SetValue("MobiCheckerTest", Application.ExecutablePath + "%autostart"); Registry looks like- C:\Users\skpaul\Desktop\StartupApp\StartupApp\bin\Debug\StartupApp.EXE%autostart In Program.cs static void Main(string[] args) //args= string[0]. { Program.LaunchedViaStartup = args != null && args.Any(arg => arg.Equals("autostart",...

get index of subtable from function args in lua

function,variables,lua,arguments
Im trying to return the value of an index of a table which is inside of another table and am doing so using the args given when a function is run so that the arg resolves to a variable name. function getsubindex(varname,index) local tbl = {} tbl.first = 99 tbl.subTbl...

Can you pass a typed array to a function within an enum in swift?

function,swift,enums,arguments
In a Swift app, I've created an enum with a function that takes an array of CLBeacon objects as it's only argument (i.e., [CLBeacon]). I get no clang errors with the enum, however when I try to use the enum, clang complains that I can't invoke the function with an...

Function as argument in python

python,function,arguments
I need to pass some function as argument in another function. So, I want to add current time to class attribute every second, for example import time class Measurement(): values = [] def add_value(self, value): print "added value" self.values.append(value) def smart_delay(input_function,args): start_time = time.time() while 5 > (time.time() - start_time):...

Extract Argument from C Macro

c,macros,arguments,c-preprocessor
I have a number of definitions consisting of two comma-separated expressions, like this: #define PIN_ALARM GPIOC,14 I want to pass the second expression of those definitions (14 in the case above) to unary macros like the following: #define _PIN_MODE_OUTPUT(n) (1U << ((n) * 2U)) How can I extract the second...

Launch executable file though IIS with arguments using asp.net MVC

c#,asp.net,asp.net-mvc,iis,arguments
Hi I am having issues lunching an exe file from within an asp.net mvc application with an argument. I am trying to consolidate several systems into one portal and remove logins from the individual systems (arguments are to communicate access level) When the exe was located on my local C...

bash script case statement needs to detect specific arguments

bash,unix,scripting,arguments,lines
I have to write this script where it will display each entry that is entered in on its own line and separate each line with "*****". I've already got that down for the most part but now I need it to detect when the word "TestError" and/or "now" is entered...

LESS CSS - Mixin Arguments and Nth-Child - without looping

css,css-selectors,arguments,less,less-mixins
I am trying to write a less argument that will associate with the id #p0x1. I would like to be able to write an argument like @ytrans = translateY(@argument * 2) then provide that argument value for each ID. #p0x1(@argument:3){@ytrans} However, I am unable to do this with the nth-child...

Passing *arg arguments from list

python,function,arguments,argument-passing
I'm in a situation when I have to call one function foo: def foo(arg1,arg2,*args): pass The problem is that I have the *args arguments stored during computing as a list. Like this: a = 'arg1' b = 'arg2' list_of_args = ['arg3','arg4','arg5'] How can I call the function foo with this...

Java Paper Rock Scissors program

java,methods,parameters,arguments
Paper rock scissors java program. Ok so the only problem I'm having now is the player's score doesn't update until the second loop around. Any suggestions? Thanks again Radiodef for your help!! Updated code below....... import java.util.Scanner; public class RPS_Game { public static void main(String[] args) { char r =...

Passing arguments to main in C using Eclipse

c,arguments,main,atoi
I have a program in Eclipse and I need to pass some arguments into main. More specifically, I need to pass 2 strings (which are numbers) and are needed to call some other functions. Here is my main: int main(int argc, char **argv) { int n = atoi(argv[0]); size_t size...

Pass symbol as Arguments

ruby-on-rails,arguments,symbols
I have a already defined and working method as, render_format(doc,host,table_info) I had this method called at some location wherein I passed the arguments as, render_format("Daily Transactions in POS", {:doc => xml,:schema_name => "#{schema_name}",:store_code => "#{store_code}"}, :sales_log => "#{sales_log}") This worked just fine. Now I have to call this method as,...

bash script echo arguments into separate lines

bash,unix,scripting,arguments,lines
I have to write this script to separate arguments entered in the command line. Here is the script so far: # template.sh function usage { echo "usage: $0 arguments ..." if [ $# -eq 1 ] then echo "ERROR: $1" fi } # Script starts after this line. case $1...

maxima: calling function with list as argument

list,function,arguments,maxima
I can do this : (%i1) myFunc(x) := x^2 + 1; myList : [1,2,3]; myFunc(myList); (%o1) myFunc(x):=x^2+1 (%o2) [1,2,3] (%o3) [2,5,10] and this as well : (%i1) kill(all); load("pdiff"); myFunc(x) := ratdisrep(taylor(diff(q('dst),'dst,x),'dst,0,5)); myFunc(1); myFunc(2); myFunc(3); (%o1) myFunc(x):=ratdisrep(taylor(diff(q('dst),'dst,x),'dst,0,5)) (%o2) [1,2,3] (%o3) (q[(6)](0)*dst^5)/120+(q[(5)](0)*dst^4)/24+(q[(4)](0)*dst^3)/6+(q[(3)](0)*dst^2)/2+q[(2)](0)*dst+q[(1)](0) (%o4)...

agrep working with del, ins arguments

r,arguments,string-matching,agrep
How can "abteam" with "ab" be matched using this code? agrep("abteam",c("acb","abd","ab"),value=T,ignore.case = TRUE,max = list(del = 10, ins = 10, sub = 10)) The result is character(0), though I specified del=10, ins=10. What is the problem? How does agrep work?...

Why aren't my commandline arguments being read?

c++,command,arguments
I am calling this in my program: std::string gameDirectory = ""; for (int i = 1; i < argc; i++) { if (argv[i] == "-game") gameDirectory = argv[i + 1]; } if (gameDirectory == "") exit(0); With the commandline argument -game demo and it refuses to set the gameDirectory. Any...

Pass custom argument to rails event model callbacks?

ruby-on-rails-4,activerecord,model,callback,arguments
Very simple question but was unable to figure this out. Is it possible to do like: after_create :log_activity(my_var) So I could write 1 method that handles all the actions ( destroy,save,update)?...

Add hash argument or string argument in a method to a hash (Ruby)

ruby,methods,hash,arguments
If the argument "entry" to the method add is a hash I need to add it to the :entries hash. If "entry" is a string "entry" needs to be set as a key in the hash and its value to nil. I have a solution below but is there a...

How to call the same function with different datatype?

c++,types,arguments
Here is a class which can be called with different datatype: template<class TDataType> void SetProperties(IndexType PropertiesId, const Variable<TDataType>& rVariable, const TDataType& Value) { mpModeler->SetProperties(PropertiesId, rVariable, Value); } where Modeler::SetProperties is defined as: template<class TDataType> void SetProperties(IndexType PropertiesId, const Variable<TDataType>& rVariable, const TDataType& Value) { if (mpModel->GetProperties(PropertiesId).get() == 0) {...

Arguments.callee - Factorial Pattern

javascript,recursion,arguments,factorial
Assuming: var x = { y: function(n){ console.log(n); console.log(n+":"+( n > 0 ? arguments.callee(n-1) + "o" : "all" )); } }; x.y(4) Console log: 4 3 2 1 0 0 -> all 1 -> o 2 -> o 3 -> o 4 -> o The first part of the console.log...

Getting nth variadic argument value (not type)

c++,arguments,variadic-templates,c++14
Ignore the missing perfect forwarding. (Assume arguments are perfectly forwarded in the real implementation.) // Base case: no args template<typename TF> void forEach2Args(TF) { } // Recursive case: some args template<typename TF, typename... Ts> void forEach2Args(TF mFn, Ts... mXs) { mFn(getNth<0>(mXs...), getNth<1>(mXs...)); forEach2Args(mFn, getAllAfter<2>(mXs...)); } int main() { int result{0};...

Python - Optional Command Line Argument

python,list,command,arguments,line
I would like to have an option -n, that will allow users to specify a size of a list. The default will be 30. So: ./findNumberOfPlayers.py -n10 I haven't done any command line arguments with python before but am confused with how to include -n10 within the program. I understand...

Function that checks Java program arguments

java,arguments
I'm trying to re-write this code in a cleaner way: public static void main(String[] args) { if(checkArgs(args) < 0) return; return; } private static int checkArgs(String[] args) { if (args.length == 0) { System.out.println("Error: No Args"); return -1; } try{ //If it's a number int myNumber = Integer.parseInt(args[0]); System.out.println("My number...

pass several arguments from a array to a function in a easy way -python-

python,arrays,function,arguments
Well i really don't know how to describe this in words but i've an easy example: def foo(x,y,z): r=x+.... a = [1,2,3] foo(a[0], a[1], a[2]) Can i do the same without calling a[n] several times? but keeping "x,y,z" definition...

Powershell Invoke-Command with PSCredential Cannot process argument transformation on parameter 'Credential'

powershell,arguments,transformation,credentials,invoke-command
I'm trying to run a powershell invoke-command call with a PSCredential as parameter. But the call fails with the error: Invoke-Command : Cannot process argument transformation on parameter 'Credential'. userName" Here is the detailed output I get : error 17-Jun-2015 14:33:53 Invoke-Command : Cannot process argument transformation on parameter 'Credential'....

How many parameter in this printf() function? [duplicate]

c,methods,arguments,printf
This question already has an answer here: How does printf handle its arguments? 5 answers I am very new to programming. Now I am learning C. Please look at this following code snippet - printf("StudentId: %d CGPA: %f", id, cgpa); printf("Name: %s StudentId: %d CGPA: %f", name, id, cgpa);...