arguments

Cannot pass function handle as an argument of a function

血红的双手。 提交于 2019-12-25 03:41:19
问题 I'm new to Matlab and I'm trying to write custom function in matlab that would take function handle as one of its arguments. I'm getting this error all the time: Error using subsindex Function 'subsindex' is not defined for values of class 'function_handle'. Trying to debug I performed following test: I run command x = fminbnd(@humps, 0.3, 1) . I proceeded as expected - I got result x = 0.6370 . So I created custom function called train and I copied ALL the code of function fminbnd to the

Linux alias question

此生再无相见时 提交于 2019-12-25 03:36:47
问题 I want to create an alias for this command "rmi" so that if I execute rmi File.txt it will actually execute ls * | grep -v File.txt | xargs rm -rf Basically I want to reorder arguments. 回答1: Script: #!/usr/bin/env bash ls * | grep -v $1 | xargs rm -rf -Save this as rmi. -do: chmod a+x rmi -Then add to path. 回答2: You can't do that with an alias. You'll need to write a script. 回答3: You don't need a script. Instead of alias, you can write a shell function: myfunc() { ls * | grep -v $1 | xargs rm

DOS batch : Different behaviour between command line and drag and drop

我的未来我决定 提交于 2019-12-25 03:18:07
问题 I'm trying to write the first argument of a command line in a file, but it works in command line and not with drag and drop. The very simple batch file ( test_echo.cmd ) is as following: @echo OFF echo %1 > echo_arg_in_file.txt` On the command line, C:\rep>test_echo.cmd "C:\rep\fichier de test.txt"` creates a file echo_arg_in_file.txt with "C:\rep\fichier de test.txt" written inside. But with a drag and drop of the file "C:\rep\fichier de test.txt" on the batch file, nothing happens... (the

R: Can you make my ugly text concacting function pretty

守給你的承諾、 提交于 2019-12-25 03:16:49
问题 I am trying to write a function what makes R interpret arguments without evaluating them and pushes them into a new string. This is what I have so far. It is very ugly but works for up to 5: pl <- pasteliteral <- function(v1='',v2='',v3='',v4='',v5='', sep="") { stopifnot(v1!="") # Sort up to 10 values if (deparse(substitute(v1)!="")) {s<-deparse(substitute(v1)) if (deparse(substitute(v2)!="")) {s<-paste(s, deparse(substitute(v2)), sep=sep) if (deparse(substitute(v3)!="")) {s<-paste(s,

How to pass arguments/parameters to a SCALA script

南笙酒味 提交于 2019-12-25 03:08:23
问题 How can we pass arguments to scala script like how we pass arguments to a shell script. 回答1: Declare your script with bash command on top like this Test.scala #!/bin/sh exec scala "$0" "$@" !# object Test { def main(args: Array[String]): Unit = { println(s"args: ${args.mkString("[", ", ", "]")}") } } It works [Desktop] ./Test.scala "scala is awesome" "java8 has lambdas" args: [scala is awesome, java8 has lambdas] More info regarding $0 and $@ 0 Expands to the name of the shell or shell script

Julia: Testing function in interactive session

▼魔方 西西 提交于 2019-12-25 02:04:13
问题 I am not sure if it is possible, but I would like to be able to grab the default argument values of a function and test them and the code within my functions without having to remove the commas (this is especially useful in the case when there are many arguments). In effect, I want to be able to have commas when sending arguments into the function but not have those commas if I copy and paste the arguments and run them by themselves. For example: function foo( x=1, y=2, z=3 ) bar(x,y,z) end

returning a variable to a method from within a switch statement

纵饮孤独 提交于 2019-12-25 01:53:22
问题 For some reason i'm loosing access to my variables inside the switch statement, I am not allowed to use any global variables. import java.util.Scanner; public class Projet { public static void main(String[] args) { String clef="vide"; Scanner in = new Scanner(System.in); showMenu(in); in.close(); } Main method is kept as clean as possible ... calling the menu just once. public static void showMenu(Scanner in){ System.out.printf("******************************************%n" + "* Choisissez

Cannot call ruby rake with parameter containing space

烈酒焚心 提交于 2019-12-25 01:45:48
问题 I have task: desc "Create a team" task :create_dev_team, [:team_name] do |t, args| puts "Creating \"#{args.team_name}\" team under Sub Org ID: 1" ESP::Team.create(name: "#{args.team_name}", sub_organization_id: 1) end I call: rake create_dev_team[Team Name] I get: rake aborted! Don't know how to build task 'create_dev_team[Team' /Users/me/.rvm/gems/ruby-2.4.1/gems/rake-10.3.2/lib/rake/task_manager.rb:62:in `[]' /Users/me/.rvm/gems/ruby-2.4.1/gems/rake-10.3.2/lib/rake/application.rb:149:in

passing arguments to functions in php

99封情书 提交于 2019-12-25 01:43:59
问题 I have some php code that is pretty much being duplicated save for some minor variable naming differences. How can I turn this into a reusable function where I can pass arguments thru? This is the code which I am using twice. The second one is the same except all references of "affiliate" is changed to "social". <?php $affiliate = wp_list_bookmarks( array( 'categorize' => 0, 'category' => '7', 'title_li' => '', 'orderby' => 'rating', 'show_images' => 0, 'echo' => 0 ) ); preg_match_all( '/<li>

Java. Why can i pass an object argument, if in the method definition the arguments are the type of an interface?

北城以北 提交于 2019-12-25 01:14:03
问题 Let's say I have the following interface: public interface Numeric { public Numeric addition(Numeric x,Numeric y); } And the following class: public class Complex implements Numeric { private int real; private int img; public Complex(int real, int img){ this.real = real; this.img = img; } public Numeric addition(Numeric x, Numeric y){ if (x instanceof Complex && y instanceof Complex){ Complex n1 = (Complex)x; Complex n2 = (Complex)y; return new Complex(n1.getReal() + n1.getReal(), n2.getImg()