Search Results

Search found 1533 results on 62 pages for 'rdbms agnostic'.

Page 17/62 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • What is technically more advanced: Python or Assembler? [closed]

    - by el ka es
    I wondered which of these languages is more powerful. With powerful I don't mean the readability, assembler would be naturally the winner here, but something resulting from, for example, the following factors: Which of them is more high-level? (Both aren't really but one has to be more) Who would be the possibly fastest in compiled state? (There is no Python compiler out there as far as I know but it wouldn't be hard writing one I suppose) Which of the both has the better code length/code action ratio? What I mean is If you get to distracted by the, compared to Python, improved readability of assembler, just think of writing plain binary/machine code as what assembler assembles to. Both languages are so basic that it should be possible to answer the question(s) in a rather objective view, I hope.

    Read the article

  • Static analysis of multiple if statements (conditions)

    - by koppernickus
    I have code similar to: if conditionA(x, y, z) then doA() else if conditionB(x, y, z) then doB() ... else if conditionZ(x, y, z) then doZ() else throw ShouldNeverHappenException I would like to validate two things (using static analysis): If all conditions conditionA, conditionB, ..., conditionZ are mutually exclusive (i.e. it is not possible that two or more conditions are true in the same time). All possible cases are covered, i.e. "else throw" statement will never be called. Could you recommend me a tool and/or a way I could (easily) do this? I would appreciate more detailed informations than "use Prolog" or "use Mathematica"... ;-)

    Read the article

  • The whole point of programming is creating abstractions

    - by Damien
    Hullo, this is Damien. I am new to programming and to StackOverflow community. Our professor once said that "the whole point of programming is creating abstractions." His explanation however went right over my head. Please explain the meaning of this sentence in simple words -- something that a noob like me can understand. Thank you!

    Read the article

  • Algorithm to generate a crossword

    - by nickf
    Given a list of words, how would you go about arranging them into a crossword grid? It wouldn't have to be like a "proper" crossword puzzle which is symmetrical or anything like that: basically just output a starting position and direction for each word.

    Read the article

  • Improper integral calculation using numerical intergration

    - by Andrei Taptunov
    I'm interested in calculation of Improper Integral for a function. Particularly it's a Gauss Integral. Using a numerical integration does make sense for a definite integrals but how should I deal with improper integrals ? Is there any was to extrapolate the function "around" negative infinity or should I just remove this part and start integration from some particular value because cumulative sum near "negative infinity" is almost non-existent for Gauss integral? Perhaps there are some algorithms that I'm not aware about.

    Read the article

  • To Throw or Not to Throw

    - by serhio
    // To Throw void PrintType(object obj) { if(obj == null) { throw new ArgumentNullException("obj") } Console.WriteLine(obj.GetType().Name); } // Not to Throw void PrintType(object obj) { if(obj != null) { Console.WriteLine(obj.GetType().Name); } } What principle to keep? Personally Personally I prefer the first one its say developer-friendly. The second one its say user-friendly. What do you think?

    Read the article

  • Code Golf: Easter Spiral

    - by friol
    What's more appropriate than a Spiral for Easter Code Golf sessions? Well, I guess almost anything. The Challenge The shortest code by character count to display a nice ASCII Spiral made of asterisks ('*'). Input is a single number, R, that will be the x-size of the Spiral. The other dimension (y) is always R-2. The program can assume R to be always odd and = 5. Some examples: Input 7 Output ******* * * * *** * * * * ***** * Input 9 Output ********* * * * ***** * * * * * * *** * * * * * ******* * Input 11 Output *********** * * * ******* * * * * * * * *** * * * * * * * * ***** * * * * * ********* * Code count includes input/output (i.e., full program). Any language is permitted. My easily beatable 303 chars long Python example: import sys; d=int(sys.argv[1]); a=[d*[' '] for i in range(d-2)]; r=[0,-1,0,1]; x=d-1;y=x-2;z=0;pz=d-2;v=2; while d>2: while v>0: while pz>0: a[y][x]='*'; pz-=1; if pz>0: x+=r[z]; y+=r[(z+1)%4]; z=(z+1)%4; pz=d; v-=1; v=2;d-=2;pz=d; for w in a: print ''.join(w); Now, enter the Spiral...

    Read the article

  • Code Golf: Finite-state machine!

    - by Adam Matan
    Finite state machine A deterministic finite state machine is a simple computation model, widely used as an introduction to automata theory in basic CS courses. It is a simple model, equivalent to regular expression, which determines of a certain input string is Accepted or Rejected. Leaving some formalities aside, A run of a finite state machine is composed of: alphabet, a set of characters. states, usually visualized as circles. One of the states must be the start state. Some of the states might be accepting, usually visualized as double circles. transitions, usually visualized as directed arches between states, are directed links between states associated with an alphabet letter. input string, a list of alphabet characters. A run on the machine begins at the starting state. Each letter of the input string is read; If there is a transition between the current state and another state which corresponds to the letter, the current state is changed to the new state. After the last letter was read, if the current state is an accepting state, the input string is accepted. If the last state was not an accepting state, or a letter had no corresponding arch from a state during the run, the input string is rejected. Note: This short descruption is far from being a full, formal definition of a FSM; Wikipedia's fine article is a great introduction to the subject. Example For example, the following machine tells if a binary number, read from left to right, has an even number of 0s: The alphabet is the set {0,1}. The states are S1 and S2. The transitions are (S1, 0) -> S2, (S1, 1) -> S1, (S2, 0) -> S1 and (S2, 1) -> S2. The input string is any binary number, including an empty string. The rules: Implement a FSM in a language of your choice. Input The FSM should accept the following input: <States> List of state, separated by space mark. The first state in the list is the start state. Accepting states begin with a capital letter. <transitions> One or more lines. Each line is a three-tuple: origin state, letter, destination state) <input word> Zero or more characters, followed by a newline. For example, the aforementioned machine with 1001010 as an input string, would be written as: S1 s2 S1 0 s2 S1 1 S1 s2 0 S1 s2 1 s2 1001010 Output The FSM's run, written as <State> <letter> -> <state>, followed by the final state. The output for the example input would be: S1 1 -> S1 S1 0 -> s2 s2 0 -> S1 S1 1 -> S1 S1 0 -> s2 s2 1 -> s2 s2 0 -> S1 ACCEPT For the empty input '': S1 ACCEPT For 101: S1 1 -> S1 S1 0 -> s2 s2 1 -> s2 REJECT For '10X': S1 1 -> S1 S1 0 -> s2 s2 X REJECT Prize A nice bounty will be given to the most elegant and short solution. Reference implementation A reference Python implementation will be published soon.

    Read the article

  • What is a good standard exercise to learn the OO features of a language?

    - by FarmBoy
    When I'm learning a new language, I often program some mathematical functions to get used to the control flow syntax. After that, I like to implement some sorting algorithms to get used to the array/list constructs. But I don't have a standard exercise for exploring the languages OO features. Does anyone have a stock exercise for this? A good answer would naturally lend to inheritance, polymorphism, etc., for a programmer already comfortable with these concepts. An ideal answer would be one that could be communicated in a few words, without ambiguity, in the way that "implement mergesort" is completely unambiguous. (As an example, answering "design a game" is so vague as to be useless.) Any ideas? EDIT: I have to remark that the results here are somewhat ironic. 10 upvotes and (originally) 5 favorites suggest that this is a question others are interested in. Yet the most upvoted answer is one that says there is no good answer. Oh well. I think I'll look at the textbook below, I've found games useful in the past for OO.

    Read the article

  • reconstructing a tree from its preorder and postorder lists.

    - by NomeN
    Consider the situation where you have two lists of nodes of which all you know is that one is a representation of a preorder traversal of some tree and the other a representation of a postorder traversal of the same tree. I believe it is possible to reconstruct the tree exactly from these two lists, and I think I have an algorithm to do it, but have not proven it. As this will be a part of a masters project I need to be absolutely certain that it is possible and correct (Mathematically proven). However it will not be the focus of the project, so I was wondering if there is a source out there (i.e. paper or book) I could quote for the proof. (Maybe in TAOCP? anybody know the section possibly?) In short, I need a proven algorithm in a quotable resource that reconstructs a tree from its pre and post order traversals. Note: The tree in question will probably not be binary, or balanced, or anything that would make it too easy. Note2: Using only the preorder or the postorder list would be even better, but I do not think it is possible. Note3: A node can have any amount of children. Note4: I only care about the order of siblings. Left or right does not matter when there is only one child.

    Read the article

  • Why do you enjoy programming?

    - by Earlz
    Some of us here(or is it just me?) enjoy programming. Even if we're not being paid for it, and in some cases, even though the end result will not do anything for us. For example, many people do the Project Euler problems just for fun, and in the end nothing was really "accomplished" materially. What is it that makes us enjoy programming? How is programming different from another job? You don't see an accountant going home to do some accounting on their own time just for the pure joy of it. How are we different? (also, if anyone has some ideas on how to tag this, then please do correct it for me.. )

    Read the article

  • Good implementations of reinforced learning?

    - by Paperino
    For an ai-class project I need to implement a reinforcement learning algorithm which beats a simple game of tetris. The game is written in Java and we have the source code. I know the basics of reinforcement learning theory but was wondering if anyone in the SO community had hands on experience with this type of thing. What would your recommended readings be for an implementation of reinforced learning in a tetris game? Are there any good open source projects that accomplish similar things that would be worth checking out? Thanks in advanced Edit: The more specific the better, but general resources about the subject are welcomed. Follow up: Thought it would be nice if I posted a followup. Here's the solution (code and writeup) I ended up with for any future students :). Paper / Code

    Read the article

  • Programmer Puzzle: Encoding a chess board state throughout a game

    - by Andrew Rollings
    Not strictly a question, more of a puzzle... Over the years, I've been involved in a few technical interviews of new employees. Other than asking the standard "do you know X technology" questions, I've also tried to get a feel for how they approach problems. Typically, I'd send them the question by email the day before the interview, and expect them to come up with a solution by the following day. Often the results would be quite interesting - wrong, but interesting - and the person would still get my recommendation if they could explain why they took a particular approach. So I thought I'd throw one of my questions out there for the Stack Overflow audience. Question: What is the most space-efficient way you can think of to encode the state of a chess game (or subset thereof)? That is, given a chess board with the pieces arranged legally, encode both this initial state and all subsequent legal moves taken by the players in the game. No code required for the answer, just a description of the algorithm you would use. EDIT: As one of the posters has pointed out, I didn't consider the time interval between moves. Feel free to account for that too as an optional extra :) EDIT2: Just for additional clarification... Remember, the encoder/decoder is rule-aware. The only things that really need to be stored are the player's choices - anything else can be assumed to be known by the encoder/decoder. EDIT3: It's going to be difficult to pick a winner here :) Lots of great answers!

    Read the article

  • Fastest sorting algorithm for a specific situation

    - by luvieere
    What is the fastest sorting algorithm for a large number (tens of thousands) of groups of 9 positive double precision values, where each group must be sorted individually? So it's got to sort fast a small number of possibly repeated double precision values, many times in a row. The values are in the [0..1] interval. I don't care about space complexity or stability, just about speed.

    Read the article

  • Graph Algorithm To Find All Paths Between N Arbitrary Vertices

    - by russtbarnacle
    I have an graph with the following attributes: Undirected Not weighted Each vertex has a minimum of 2 and maximum of 6 edges connected to it. Vertex count will be < 100 I'm looking for paths between a random subset of the vertices (at least 2). The paths should simple paths that only go through any vertex once. My end goal is to have a set of routes so that you can start at one of the subset vertices and reach any of the other subset vertices. Its not necessary to pass through all the subset nodes when following a route. All of the algorithms I've found (Dijkstra,Depth first search etc.) seem to be dealing with paths between two vertices and shortest paths. Is there a known algorithm that will give me all the paths (I suppose these are subgraphs) that connect these subset of vertices?

    Read the article

  • Tooltips with infinite timeout?

    - by romkyns
    I'm thinking of setting the timeout on all my tooltips in a WinForms application to infinity (or an extremely large value). The motivation is that it's annoying for the user if the tooltip disappears while I'm still reading it, without providing any extra value whatsoever as far as I can tell. Normally I wouldn't ask something like this on StackOverflow, but the overwhelming majority of all software sets timeouts on tooltips, so it makes me wonder whether perhaps there is some important consideration I'm missing? Or is this just an old convention that nobody gives further thought to? If you would hate infinite timeout as opposed to a short timeout, please explain why. (If you just think tooltips are a bad idea altogether then that's a separate consideration; this question is specifically about the infinite timeout.)

    Read the article

  • Any software for pattern-matching and -rewriting source code?

    - by Steven A. Lowe
    I have some old software (in a language that's not dead but is dead to me ;-)) that implements a basic pattern-matching and -rewriting system for source code. I am considering resurrecting this code, translating it into a modern language, and open-sourcing the project as a refactoring power-tool. Before I go much further, I want to know if anything like this exists already (my google-fu is fanning air on this tonight). Here's how it works: the pattern-matching part matches source-code patterns spanning multiple lines of code using a template with binding variables, the pattern-rewriting part uses a template to rewrite the matched code, inserting the contents of the bound variables from the matching template matching and rewriting templates are associated (1:1) by a simple (unconditional) rewrite rule the software operates on the abstract syntax tree (AST) of the input application, and outputs a modified AST which can then be regenerated into new source code for example, suppose we find a bunch of while-loops that really should be for-loops. The following template will match the while-loop pattern: Template oldLoopPtrn int @cnt@ = 0; while (@cnt@ < @max@) { … @body@ ++@cnt@; } End_Template while the following template will specify the output rewrite pattern: Template newLoopPtrn for(int @cnt@ = 0; @cnt@ < @max@; @cnt@++) { @body@ } End_Template and a simple rule to associate them Rule oldLoopPtrn --> newLoopPtrn so code that looks like this int i=0; while(i<arrlen) { printf("element %d: %f\n",i,arr[i]); ++i; } gets automatically rewritten to look like this for(int i = 0; i < arrlen; i++) { printf("element %d: %f\n",i,arr[i]); } The closest thing I've seen like this is some of the code-refactoring tools, but they seem to be geared towards interactive rewriting of selected snippets, not wholesale automated changes. I believe that this kind of tool could supercharge refactoring, and would work on multiple languages (even HTML/CSS). I also believe that converting and polishing the code base would be a huge project that I simply cannot do alone in any reasonable amount of time. So, anything like this out there already? If not, any obvious features (besides rewrite-rule conditions) to consider? EDIT: The one feature of this system that I like very much is that the template patterns are fairly obvious and easy to read because they're written in the same language as the target source code, not in some esoteric mutated regex/BNF format.

    Read the article

  • Genetic Programming Online Learning

    - by Lirik
    Has anybody seen a GP implemented with online learning rather than the standard offline learning? I've done some stuff with genetic programs and I simply can't figure out what would be a good way to make the learning process online. Please let me know if you have any ideas, seen any implementations, or have any references that I can look at.

    Read the article

  • Do you still limit line length in code?

    - by Noldorin
    This is a matter on which I would like to gauge the opinion of the community: Do you still limit the length of lines of code to a fixed maximum? This was certainly a convention of the past for many languages; one would typically cap the number of characters per line to a value such as 80 (and more recnetly 100 or 120 I believe). As far as I understand, the primary reasons for limiting line length are: Readability - You don't have to scroll over horizontally when you want to see the end of some lines. Printing - Admittedly (at least in my experience), most code that you are working on does not get printed out on paper, but by limiting the number of characters you can insure that formatting doesn't get messed up when printed. Past editors (?) - Not sure about this one, but I suspect that at some point in the distant past of programming, (at least some) text editors may have been based on a fixed-width buffer. I'm sure there are points that I am still missing out, so feel free to add to these... Now, when I tend to observe C or C# code nowadays, I often see a number of different styles, the main ones being: Line length capped to 80, 100, or even 120 characters. As far as I understand, 80 is the traditional length, but the longer ones of 100 and 120 have appeared because of the widespread use of high resolutions and widescreen monitors nowadays. No line length capping at all. This tends to be pretty horrible to read, and I don't see it too often, though it's certainly not too rare either. Inconsistent capping of line length. The length of some lines are limited to a fixed maximum (or even a maximum that changes depending on the file/location in code), while others (possibly comments) are not at all. My personal preference here (at least recently) has been to cap the line length to 100 in the Visual Studio editor. This means that in a decently sized window (on a non-widescreen monitor), the ends of lines are still fully visible. I can however see a few disadvantages in this, especially when you end up writing code that's indented 3 or 4 levels and then having to include a long string literal - though I often take this as a sign to refactor my code! In particular, I am curious what the C and C# coders (or anyone who uses Visual Studio for that matter) think about this point, though I would be interested in hearing anyone's thoughts on the subject. Edit Thanks for the all answers - I appreciate the variety of opinions here, all presenting sound reasons. Consensus does seem to be tipping in the direction of always (or almost always) limit the line length. Interestingly, it seems to be in various coding standards to limit the line length. Judging by some of the answers, both the Python and Google CPP guidelines set the limit at 80 chars. I haven't seen anything similar regarding C# or VB.NET, but I would be curious to see if there are ones anywhere.

    Read the article

  • Code Golf: Zigzag pattern scanning

    - by fbrereto
    The Challenge The shortest code by character count that takes a single input integer N (N = 3) and returns an array of indices that when iterated would traverse an NxN matrix according to the JPEG "zigzag" scan pattern. The following is an example traversal over an 8x8 matrix (referenced from here:) Examples (The middle matrix is not part of the input or output, just a representation of the NxN matrix the input represents.) 1 2 3 (Input) 3 --> 4 5 6 --> 1 2 4 7 5 3 6 8 9 (Output) 7 8 9 1 2 3 4 (Input) 4 --> 5 6 7 8 --> 1 2 5 9 6 3 4 7 10 13 14 11 8 12 15 16 (Output) 9 10 11 12 13 14 15 16 Notes: The resulting array's base should be appropriate for your language (e.g., Matlab arrays are 1-based, C++ arrays are 0-based). This is related to this question.

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >