Search Results

Search found 12674 results on 507 pages for 'programming competitions'.

Page 195/507 | < Previous Page | 191 192 193 194 195 196 197 198 199 200 201 202  | Next Page >

  • Sequential WSASend() calls - can I rely on TCP to put them on the wire in the posting order?

    - by Poni
    On Windows I/O completion ports, say I do this: void function() { WSASend("1111"); // A WSASend("2222"); // B WSASend("3333"); // C } If I got a "write-complete" that says 3 bytes of WSASend() A were sent, is it possible that right after that I'll get a "write-complete" that tells me that some or all of B & C were sent, or will TCP will hold them until I re-issue a WSASend() call with the rest of A's data? Or will TCP complete it automatically?

    Read the article

  • Game network physics collision

    - by Jonas Byström
    How to simulating two client-controlled vehicles colliding (sensibly) in a typical client/server setup for a network game? I did read this eminent blog post on how to do distributed network physics in general (without traditional client prediction), but this question is specifically on how to handle collisions of owned objects. Example Say client A is 20 ms ahead of server, client B 300 ms ahead of server (counting both latency and maximum jitter). This means that when the two vehicles collide, both clients will see the other as 320 ms behind - in the opposite direction of the velocity of the other vehicle. Head-to-head on a Swedish highway means a difference of 16 meters/17.5 yards! What not to try It is virtually impossible to extrapolate the positions, since I also have very complex vehicles with joints and bodies all over, which in turn have linear and angular positions, velocities and accelerations, not to mention states from user input.

    Read the article

  • Assign pointers in objective C

    - by Tattat
    -(id)setBigObject:(BigObject *)abc{ self.wl = abc; abc.smallObject = self.smallObject; } I have a abc, which is a big Object, when the user pass the bigObject, abc. I assign to my wl value, so , I write "self.wl = abc;", but I want my smallObject assign to the abc's smallObject, so, I do "abc.smallObject = self.smallObject; " So, when I edit the smallObject in self, it will also changed in the abc's also? Am I right?

    Read the article

  • Why is Objective-C not very popular outside of the Apple community?

    - by Tattat
    I know that the Apple community – including Mac and iPhone developers – mainly use Objective-C for their development language. But it seems that not many people use Objective-C outside of the Apple community, such as in the Windows or Linux worlds. What are the possible reasons that Objective-C is not particularly popular outside of the Apple community?

    Read the article

  • Using enum values to represent binary operators (or functions)

    - by Bears will eat you
    I'm looking for an elegant way to use values in a Java enum to represent operations or functions. My guess is, since this is Java, there just isn't going to be a nice way to do it, but here goes anyway. My enum looks something like this: public enum Operator { LT, LTEQ, EQEQ, GT, GTEQ, NEQ; ... } where LT means < (less than), LTEQ means <= (less than or equal to), etc - you get the idea. Now I want to actually use these enum values to apply an operator. I know I could do this just using a whole bunch of if-statements, but that's the ugly, OO way, e.g.: int a = ..., b = ...; Operator foo = ...; // one of the enum values if (foo == Operator.LT) { return a < b; } else if (foo == Operator.LTEQ) { return a <= b; } else if ... // etc What I'd like to be able to do is cut out this structure and use some sort of first-class function or even polymorphism, but I'm not really sure how. Something like: int a = ..., b = ...; Operator foo = ...; return foo.apply(a, b); or even int a = ..., b = ...; Operator foo = ...; return a foo.convertToOperator() b; But as far as I've seen, I don't think it's possible to return an operator or function (at least, not without using some 3rd-party library). Any suggestions?

    Read the article

  • What 20 Lines (or less) of code did you find really useful?

    - by Ygam
    You can share your code or other's code. Here's a snippet from an array function in Kohana: public static function rotate($source_array, $keep_keys = TRUE) { $new_array = array(); foreach ($source_array as $key => $value) { $value = ($keep_keys === TRUE) ? $value : array_values($value); foreach ($value as $k => $v) { $new_array[$k][$key] = $v; } } return $new_array; } It was helpful when I was uploading multiple images using multiple file upload forms. It turned this array array('images' => array( 'name' => array( 0 => 'img1', 1 => 'img0', 2 =>'img2' ), 'error' => array( 0 => '', 1 => '', 2 => '' into : array('images' => array( 0 => array( 'name' => 'img1' 'error' => '' ),//rest goes here How about you? What 20 or less lines of code did you find useful?

    Read the article

  • What is my error in a map in java?

    - by amveg
    Hello everyone I am trying to solve this problem: http://www.cstutoringcenter.com/problems/problems.php?id=4, but I cant figure out why my code doesnt solve this, I mean in the "for" how can I can multiply the letters? what is my error?, It just tell always 7, but I want to multiple all the letters, I hope you can help me enter code here public class ejercicio3 { public static void main(String args[]) { Map<Character, Integer> telefono = new HashMap<Character, Integer>(); telefono.put('A', 2); telefono.put('B', 2); telefono.put('C', 2); telefono.put('D', 3); telefono.put('E', 3); telefono.put('F', 3); telefono.put('G', 4); telefono.put('H', 4); telefono.put('I', 4); telefono.put('J', 5); telefono.put('K', 5); telefono.put('L', 5); telefono.put('M', 6); telefono.put('N', 6); telefono.put('O', 6); telefono.put('P', 7); telefono.put('R', 7); telefono.put('S', 7); telefono.put('T', 8); telefono.put('U', 8); telefono.put('V', 8); telefono.put('W', 9); telefono.put('X', 9); telefono.put('Y', 9); String mensaje = "Practice"; int producto = 1; for (char c : mensaje.toCharArray()) { if (telefono.containsKey(c)) { producto = telefono.get(c) * producto; System.out.println(producto); } } } }

    Read the article

  • .NET framework is copied to 'compiler/CLR' and 'GAC?

    - by prosseek
    The book of CLR via C# has this line at page 76. When you install the .NET Framework, tow copies of Microsoft's assembly files are actuall installed. One set is installed into the compiler/CLR directory, and another set is installed into GAC subdirectory I could find the GAC at C:\Windows\Microsoft.NET\assembly, but I couldn't find the compiler/CLR thing. What's the physical directory name of compiler/CLR? I mean, where is it? Why there are two GAC in assembly directory? I find GAC_32 and GAC_MSIL.

    Read the article

  • What to do with someone who can only use "the one true language"?

    - by Rob Wells
    G'day, How do you work with someone when they haven't been able to see that there is a range of other languages out there beyond "The One True Path"? I mean someone who hasn't grown up to realise that the modern software professional has a range of tools in his toolbox. Someone who has a well-equipped toolbox and then selects the best tool for the job at hand. The person who's knee jerk reaction is, for example, "We must do this is C++!" "Everything must be done in C++!" What's the best approach for these people? How do you open them up to the fact that "not everything is a nail." cheers,

    Read the article

  • Is the FoldLeft function available in R?

    - by JSmaga
    Hi, I would like to know if there is an implementation of the foldLeft function (and foldRight?) in R. The language is supposed to be "rather" functional oriented and hence I think there should be something like this, but I could not find it in the documentation. To me, foldLeft function applies on a list and has the following signature: foldLeft[B](z : B)(f : (B, A) => B) : B It is supposed to return the following result: f(... (f(f(z, a0), a1) ...), an) if the list is [a0, a1, ..., an]. (I use the definition of the Scala List API) Does anybody know if such a function exists in R?

    Read the article

  • Protecting IP for scripting projects

    - by Francisco Garcia
    There are some tasks where the obvious language choice is with scripting languages: bash, Python, Ruby, Tcl... however I find it hard to protect a company IP once the product is delivered because the application is never compiled. The client will have complete access to every single line of code. Which one are the choices to protect a product IP when it is best implemented with scripting languages? (switching to a compiled language such as C++ should not be an option) I know that some interpreted languages can be compiled, but there are cases where the process can be inverted

    Read the article

  • Using LINQ, need help splitting a byte array on data received from Silverlight sockets

    - by gcadmes
    The message packats received contains multiple messages deliniated by a header=0xFD and a footer=0xFE // sample message packet with three // different size messages List<byte> receiveBuffer = new List<byte>(); receiveBuffer.AddRange(new byte[] { 0xFD, 1, 2, 0xFE, 0xFD, 1, 2, 3, 4, 5, 6, 7, 8, 0xFE, 0xFD, 33, 65, 25, 44, 0xFE}); // note: this sample code is without synchronization, // statements, error handling...etc. while (receiveBuffer.Count > 0) { var bytesInRange = receiveBuffer.TakeWhile(n => n != 0xFE); foreach (var n in bytesInRange) Console.WriteLine(n); // process message.. // 1) remove bytes read from receive buffer // 2) construct message object... // 3) etc... receiveBuffer.RemoveRange(0, bytesInRange.Count()); } As you can see, (including header/footer) the first message in this message packet contains 4 bytes, and the 2nd message contains 10 bytes,a and the 3rd message contains 6 bytes. In the while loop, I was expecting the TakeWhile to add the bytes that did not equal the footer part of the message. Note: Since I am removing the bytes after reading them, the header can always be expected to be at position '0'. I searched examples for splitting byte arrays, but non demonstrated splitting on arrays of unknown and fluctuating sizes. Any help will be greatly appreciated. thanks much!

    Read the article

  • Why call-by-value evaluation strategy is not Turing complete?

    - by Roman
    I'm reading an article about different evaluation strategies (I linked article in wiki, but I'm reading another one not in English). And it says that unlike to call-by-name and call-by-need strategies, call-by-value strategy is not Turing complete. Can anybody explain, please, why is it so? If it's possible, add an example pls.

    Read the article

  • What advantage does Monad give us over an Applicative?

    - by arrowdodger
    I've read this article, but didn't understand last section. The author says that Monad gives us context sensitivity, but it's possible to achieve the same result using only an Applicative instance: let maybeAge = (\futureYear birthYear -> if futureYear < birthYear then yearDiff birthYear futureYear else yearDiff futureYear birthYear) <$> (readMay futureYearString) <*> (readMay birthYearString) It's uglier for sure, but beside that I don't see why we need Monad. Can anyone clear this up for me?

    Read the article

  • Cartesian Plane

    - by NuNu
    I'm trying to define a function in Haskell that takes an integer argument c and returns the list of all points on the cartesian plane of the form (x/c,y/c) where x and y are integers. x/c is between -2 and 1 and y/r is between -1 and 1 This is what I've gotten so far which I'm almost sure is right but I'm getting a parse error on input = when I run it particularly at this line: cart xs ys c = [(y/c,x/c) | x <- xs, y <- ys] plane :: Int -> [a] plane c = cart [-1*c .. 1*c] [-2*c .. 1*c] c cart xs ys c = [(y/c,x/c) | x <- xs, y <- ys] A sample output would be: plane 1 would generate: [(-2.0, -1.0), (-1.0, -1.0), ( 0.0, -1.0), ( 1.0, -1.0), (-2.0, 0.0), (-1.0, 0.0), ( 0.0, 0.0), ( 1.0, 0.0), (-2.0, 1.0), (-1.0, 1.0), ( 0.0, 1.0), ( 1.0, 1.0)] Anyone have any idea how I can fix this! Thanks

    Read the article

  • errors on shell

    - by lego69
    somebody knows what does this error mean? Usage: tcsh [ -bcdefilmnqstvVxX ] [ argument ... ]. I receive this error after I enter in my script this row #! /bin/tcsh -f

    Read the article

< Previous Page | 191 192 193 194 195 196 197 198 199 200 201 202  | Next Page >