Search Results

Search found 7418 results on 297 pages for 'argument passing'.

Page 205/297 | < Previous Page | 201 202 203 204 205 206 207 208 209 210 211 212  | Next Page >

  • Converting a C# code to F#??

    - by Brendon
    Hello all I am just a beginner in programing i wish covert some code from C# to F#, I have encotered this code: float[] v1=new float[10]; ... //Enqueue the Execute command. Queue.Execute(kernelVecSum, null, **new long[] { v1.Length }**, null, null); I have previously ask how to convert the v1 object, I think i know how, But how do i use the function call especially the "new long[] { v1.Length }" part of the function argument, what does "new long[] { v1.Length }" mean?? I have created v1 like this "let v1 = [| for i in 1.0 .. 10.0 -> 2.0 * i |]" Is it correct?? or should i use v1 like this "let v1 = ref [| for i in 1.0 .. 10.0 -> 2.0 * i |]" ???

    Read the article

  • How to test if a string has a certain unicode char?

    - by Ruben Trancoso
    Supose you have a command line executable that receives arguments. This executalbe is widechar ready and you want to test if one of this arguments starts with an HYPHEN case in which its an option: command -o foo how you could test it inside your code if you don't know the charset been used by the host? Should be not possible to a given console to produce the same HYPHEN representation by another char in the widechar forest? (in such case it would be a wild char :P) int _tmain(int argc, _TCHAR* argv[]) { std::wstring inputFile(argv[1]); if(inputFile->c_str() <is an HYPHEN>) { _tprintf(_T("First argument cannot be an option")); } }

    Read the article

  • measuring uncertainty in matlabs svmclassify

    - by Mark
    I'm doing contextual object recognition and I need a prior for my observations. e.g. this space was labeled "dog", what's the probability that it was labeled correctly? Do you know if matlabs svmclassify has an argument to return this level of certainty with it's classification? If not, matlabs svm has the following structures in it: SVM = SupportVectors: [11x124 single] Alpha: [11x1 double] Bias: 0.0915 KernelFunction: @linear_kernel KernelFunctionArgs: {} GroupNames: {11x1 cell} SupportVectorIndices: [11x1 double] ScaleData: [1x1 struct] FigureHandles: [] Can you think of any ways to compute a good measure of uncertainty from these? (Which support vector to use?) Papers/articles explaining uncertainty in SVMs welcome. More in depth explanations of matlabs SVM are also welcome. If you can't do it this way, can you think of any other libraries with SVMs that have this measure of uncertainty?

    Read the article

  • Row/column counter in 'apply' functions

    - by mortalitysequence
    What if one wants to apply a functon i.e. to each row of a matrix, but also wants to use as an argument for this function the number of that row. As an example, suppose you wanted to get the n-th root of the numbers in each row of a matrix, where n is the row number. Is there another way (using apply only) than column-binding the row numbers to the initial matrix, like this? test <- data.frame(x=c(26,21,20),y=c(34,29,28)) t(apply(cbind(as.numeric(rownames(test)),test),1,function(x) x[2:3]^(1/x[1]))) P.S. Actually if test was really a matrix : test <- matrix(c(26,21,20,34,29,28),nrow=3) , rownames(test) doesn't help :( Thank you.

    Read the article

  • Go - Concurrent method

    - by nevalu
    How to get a concurrent method? In my case, the library would be called from a program to get a value to each argument str --in method Get()--. When it's used Get() then it assigns a variable from type bytes.Buffer which it will have the value to return. The returned values --when it been concurrently called-- will be stored into a database or a file and it doesn't matter that its output been of FIFO way (from method). type test struct { foo uint8 bar uint8 } func NewTest(arg1 string) (*test, os.Error) {...} func (self *test) Get(str string) ([]byte, os.Error) { var format bytes.Buffer ... } I think that all code inner of method Get() should be put inner of go func() {...}(), and then to use a channel. Would there be a problem if it's called another method from Get()? Or would it also has to be concurrent?

    Read the article

  • Assigning function within function object without invoking the function itself.

    - by webzide
    Dear experts, I am trying to assign an function within an function object property without actually invoking then function itself. for instance, I have the following function object class definition function objectOne(name, value, id){ this.name=name; this.value=value; this.id=id; this.methodOne=methodFunction(this); } the last line this.methodOne=methodFunction(this); I want to pass the current object to the function but at the same time i don't want to execute the function right now. But if I do it this way without the bracket this.methodOne=methodFunction then the argument of this object would not be passed as a parameter to the function. Is there a way to work through this. Thank you in advance

    Read the article

  • Should we avoid to use Object as the input parameter/ output value of a method?

    - by developer.cyrus
    Take Java syntax as an example, though the question itself is language independent. If the following snippet takes an object MyAbstractEmailTemplate as input argument in the method setTemplate, the class MyGateway will then become tightly-coupled with the object MyAbstractEmailTemplate, which lessens the re-usability of the class MyGateway. A compromise is to use dependency-injection to ease the instantiation of MyAbstractEmailTemplate. This might solve the coupling problem to some extent, but the interface is still rigid, hardly providing enough ?exibility to other developers/ applications. So if we only use primitive data type (or even plain XML in web service) as the input/ output of a method, it seems the coupling problem no longer exists. So what do you think? public class MyGateway { protected MyAbstractEmailTemplate template; publoc void setTemplate(MyAbstractEmailTemplate template) { this.template = template; } }

    Read the article

  • Are volatile data members trivially copyable?

    - by Lightness Races in Orbit
    Whilst writing this answer I realised that I'm not as confident about my conclusions as I usually would ensure before hitting Post Your Answer. I can find a couple of reasonably convincing citations for the argument that the trivial-copyability of volatile data members is either implementation defined or flat-out false: https://groups.google.com/forum/?fromgroups=#!topic/comp.std.c++/5cWxmw71ktI http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48118 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3159.html#496 But I haven't been able to back this up in the standard1 itself. Particularly "worrying" is that there's no sign of the proposed wording change from that n3159 issues list in the actual standard's final wording. So, what gives? Are volatile data members trivially copyable, or not? 1   C++11

    Read the article

  • StructureMap IoC problem getting the instance in runtime

    - by user274269
    i have 2 concrete types "CategoryFilter" & "StopWordsFilter" that implements "IWordTokensFilter". Below is my setup: ForRequestedType<IWordTokensFilter>().TheDefaultIsConcreteType<CategoryFilter>() .AddInstances(x => { x.OfConcreteType<StopWordsFilter>(); } ); The problem is the run-time when structure map auto inject it on my class, bec. i have arguments with same plugin-type: public ClassA(IWordTokensFilter stopWordsFilter, IWordTokensFilter categoryFilter) i'm always getting CategoryFilter in my first argument but it should be stopWordsFilter. How can i setup this in a right way? thanks in advance

    Read the article

  • Why are C, C++, and LISP so prevalent in embedded devices and robots?

    - by David
    It seems that the software language skills most sought for embedded devices and robots are C, C++, and LISP. Why haven't more recent languages made inroads into these applications? For example, Erlang would seem particularly well-suited to robotic applications, since it makes concurrent programming easier and allows hot swapping of code. Python would seem to be useful, if for no other reason than its support of multiple programming paradigms. I'm even surprised that Java hasn't made a foray into general robotic programming. I'm sure one argument would be, "Some newer languages are interpreted, not compiled" - implying that compiled languages are quicker and use fewer computational resources. Is this still the case, in a time when we can put a Java Virtual Machine on a cell phone or a SunSpot? (and isn't LISP interpreted anyway?)

    Read the article

  • Overloading Console.ReadLine possible? (or any static class method)

    - by comecme
    I'm trying to create an overload of the System.Console.ReadLine() method that will take a string argument. My intention basically is to be able to write string s = Console.ReadLine("Please enter a number: "); in stead of Console.Write("Please enter a number: "); string s = Console.ReadLine(); I don't think it is possible to overload Console.ReadLine itself, so I tried implementing an inherited class, like this: public static class MyConsole : System.Console { public static string ReadLine(string s) { Write(s); return ReadLine(); } } That doesn't work though, cause it is not possible to inherit from System.Console (because it is a static class which automatically makes is a sealed class). Does it make sense what I'm trying to do here? Or is it never a good idea to want to overload something from a static class?

    Read the article

  • PHP: documentElement->childNodes warning

    - by jun
    $xml = file_get_contents(example.com); $dom = new DomDocument(); $dom->loadXML($xml); $items = $dom->documentElement; foreach($items->childNodes as $item) { $childs = $item->childNodes; foreach($childs as $i) { echo $i->nodeValue . "<br />"; } } Now I get this warning in every 2nd foreach: Warning: Invalid argument supplied for foreach() in file_example.php on line 14 Please help guys. Thanks!

    Read the article

  • How to protect against GHC7 compiled programs taking all memory?

    - by Petr Pudlák
    When playing with various algorithms in Haskell it often happens to me that I create a program with a memory leak, as it often happens with lazy evaluation. The program taking all the memory isn't really fun, I often have difficulty killing it if I realize it too late. When using GHC6 I simply had export GHCRTS='-M384m' in my .bashrc. But in GHC7 they added a security measure that unless a program is compiled with -rtsopts, it simply fails when it is given any RTS option either on a command line argument or in GHCRTS. Unfortunately, almost no Haskell programs are compiled with this flag, so setting this variable makes everything to fail (as I discovered in After upgrading to GHC7, all programs suddenly fail saying "Most RTS options are disabled. Link with -rtsopts to enable them."). Any ideas how to make any use of GHCRTS with GHC7, or another convenient way how to prevent my programs taking all memory?

    Read the article

  • process all links but external ones (ruby + mechanize)

    - by Radek
    I want to process all links but external ones from the whole web site. Is there any easy way how to identify that the link is external and skip it? My code looks so far like (the site url is passed through command line argument require 'mechanize' def process_page(page) puts puts page.title STDIN.gets page.links.each do |link| process_page($agent.get(link.href)) end end $agent = WWW::Mechanize.new $agent.user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4' process_page($agent.get(ARGV[0]))

    Read the article

  • How can I pass Arguments to a C++ program started by the Registry?

    - by Y_Y
    Hello, I'm creating a Win32 program that will be executed every time the computer turns on. I manage to do this by adding the .exe path into the registry. The problem is; I want to make the program appear minimized in the system tray when the computer is turned on but if I double click it [after the computer turns on and the program is not currently running] the program should appear on its normal [maximized] size. Question, I was thinking on whether is was possible to pass an argument to the program when the program is executed from the registry. Is this possible? If yes/no, how would I manage to do this? (Using windows XP) Thanks.

    Read the article

  • How to get Path Separator in Perl?

    - by ram
    In case of Java, we can get the path separator using System.getProperty("path.separator"); Is there a similar way in Perl? All I want to do is to find a dir, immediate sub directory. Say I am being given two argumens $a and $b; I am splitting the first one based on the path separator and joining it again except the last fragment and comparing with the second argument. The problem is my code has to be generic and for that I need to know whats the system dependent path separator is? Could you help if there is any way to get it? TIA

    Read the article

  • Why does the Scala compiler disallow overloaded methods with default arguments?

    - by soc
    While there might be valid cases where such method overloadings could become ambiguous, why does the compiler disallow code which is neither ambiguous at compile time nor at run time? Example: // This fails: def foo(a: String)(b: Int = 42) = a + b def foo(a: Int) (b: Int = 42) = a + b // This fails, too. Even if there is no position in the argument list, // where the types are the same. def foo(a: Int) (b: Int = 42) = a + b def foo(a: String)(b: String = "Foo") = a + b // This is OK: def foo(a: String)(b: Int) = a + b def foo(a: Int) (b: Int = 42) = a + b // Even this is OK. def foo(a: Int)(b: Int) = a + b def foo(a: Int)(b: String = "Foo") = a + b val bar = foo(42)_ // This complains obviously ... Are there any reasons why these restrictions can't be loosened a bit? Especially when converting heavily overloaded Java code to Scala default arguments are a very important and it isn't nice to find out after replacing plenty of Java methods by one Scala methods that the spec/compiler imposes arbitrary restrictions.

    Read the article

  • How to move file pointer to a particular location using fseek()?

    - by Noge
    My intention is to read every elements in the 2nd column into a buffer[] from the following .txt file: 9992891234 09.920 15.771 11.909 9992345971 07.892 12.234 09.234 9992348971 64.567 70.456 50.987 9992348231 89.234 85.890 58.982 I have know of a way to do it by using fscanf(): for (int i=0;i<4;i++) { fscanf(pFile, "%lld", &junk); fscanf(pFile, "%f", &buffer[i]); fscanf(pFile, "%f", &junk); fscanf(pFile, "%f", &junk); } However, since I'm doing parallel programing which requires me to use different Windows Threads to read different columns, so I'll need to read the elements in the 2nd column directly using fseek(). The question here is, what should I put in the 2nd argument in fseek() in the code below to move my file pointer to read the 2nd element of the 2nd line? fscanf(pFile, "%llf", &junk);//<------this is used to skip the 1st data for (int i=0;i<4;i++) { fscanf(pFile, "%f", &buffer[i]); fseek ( pFile , ??, SEEK_CUR );//<----how do I calculate this offset? }

    Read the article

  • Array::ConvertAll in managed C++

    - by danny.lesnik
    This is a continuation from this post. I'm trying to parse this string in managed C++: String ^ rgba = "[0.09019608,0.5176471,0.9058824,1]"; cli::array<System::Double> ^ RGB = System::Array::ConvertAll<String,cli::array<System::Double> >((rgba->Substring(1,rgba->Length-2)->Split(',')),double::Parse); Compiler throws me the following error: Error 15 error C2770: invalid explicit generic argument(s) for 'cli::array<Type,dimension> ^System::Array::ConvertAll(cli::array<TInput,1> ^,System::Converter<TInput,TOutput> ^)' What am I doing wrong?

    Read the article

  • SQL SELECT multiple INNER JOINs

    - by Noam Smadja
    The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect its Access database.. i have a Library table, where Autnm Topic Size Cover Lang are foreign Keys each record is actually a book which has its properties such as author and stuff. i am not quite sure i am even using the correct JOIN.. quite new with "complex" SQL :) SELECT Library.Bknm_Hebrew, Library.Bknm_English, Library.Bknm_Russian, Library.Note, Library.ISBN, Library.Pages, Library.PUSD, Author.ID AS [AuthorID], Author.Author_hebrew AS [AuthorHebrew], Author.Author_English AS [AuthorEnglish], Author.Author_Russian AS [AuthorRussian], Topic.ID AS [TopicID], Topic.Topic_Hebrew AS [TopicHebrew], Topic.Topic_English AS [TopicEnglish], Topic.Topic_Russian AS [TopicRussian], Size.Size AS [Size], Cover.ID AS [TopicID], Cover.Cvrtyp_Hebrew AS [CoverHebrew], Cover.Cvrtyp_English AS [TopicEnglish], Cover.Cvrtyp_Russian AS [CoverRussian], Lang.ID AS [LangID], Lang.Lang_Hebrew AS [LangHebrew], Lang.Lang_English AS [LangEnglish], FROM Library INNER JOIN Author ON Library.Autnm = Author.ID INNER JOIN Topic ON Library.Topic = Topic.ID INNER JOIN Size ON Library.Size = Size.ID INNER JOIN Cover ON Library.Cover = Cover.ID INNER JOIN Lang ON Library.Lang = Lang.ID Thx in advance

    Read the article

  • Python - Removing duplicates from a string

    - by Daniel
    def remove_duplicates(strng): """ Returns a string which is the same as the argument except only the first occurrence of each letter is present. Upper and lower case letters are treated as different. Only duplicate letters are removed, other characters such as spaces or numbers are not changed. >>> remove_duplicates('apple') 'aple' >>> remove_duplicates('Mississippi') 'Misp' >>> remove_duplicates('The quick brown fox jumps over the lazy dog') 'The quick brown fx jmps v t lazy dg' >>> remove_duplicates('121 balloons 2 u') '121 balons 2 u' """ s = strng.split() return strng.replace(s[0],"") Writing a function to get rid of duplicate letters but so far have been playing around for an hour and can't get anything. Help would be appreciated, thanks.

    Read the article

  • Is it possible to start an activity from a regular java class?

    - by Yotam
    In my ActionBarSherlock I have the same menu items for all activities, so it seems unwise to define onClick handlers in each activity - they all do the same. Instead I created a class called MyClickListener that implements com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener, and in there I have a simple switch block that starts the appropriate activity. Problem is that Intent constructor's first argument is of type Context, and even when I pass this to MyClickListener's constructor, I can't start any activity. The same goes for every method that has a Context object as a parameter. Is there a way to work around it? What is a context object? Thanks

    Read the article

  • How to Break out of multiple loops at once in C#?

    - by Rosarch
    What if I have nested loops, and I want to break out of all of them at once? while (true) { // ... while (shouldCont) { // ... while (shouldGo) { // ... if (timeToStop) { break; // break out of everything? } } } } In PHP, break takes an argument for the number of loops to break out of. Can something like this be done in C#? What about something hideous, like goto? // in the innermost loop goto BREAK // ... BREAK: break; break; break;

    Read the article

  • Howto disable the emacs site-start files permanently?

    - by elemakil
    When solving this problem I figured out that I need to disable the site-wise init files in order to get my emacs + CEDET running (everything works nicely when starting emacs using emacs --no-site-file but is broken without the additional argument). I'd like to disable the site-wise init files permanently but as I'm using several different approaches/methods when launching emacs (launcher/panel/terminal) I don't think aliasing it in my .zshrc won't work. I require a method to permanently disable all site-start files. Is there any easy way to achieve this? Thanks!

    Read the article

  • Using generics in dotnet for functions with any number of arguments?

    - by Zarigani
    I would like to have a function that can "wrap" any other function call. In this particular case, it would allow me to write some more generic transaction handling around some specific operations. I can write this for any particular number of arguments, e.g. for one argument: Public Shared Sub WrapFunc(Of T)(ByVal f As Action(Of T), ByVal arg As T) ' Test some stuff, start transaction f(arg) ' Test some stuff, end transaction End Sub ... but I was hoping to have this handle any number of arguments without having to have duplicate code for 0 args, 1 arg, 2 args, etc. Is there a way of doing this?

    Read the article

< Previous Page | 201 202 203 204 205 206 207 208 209 210 211 212  | Next Page >