Search Results

Search found 160 results on 7 pages for 'repetition'.

Page 1/7 | 1 2 3 4 5 6 7  | Next Page >

  • Using explicitly numbered repetition instead of question mark, star and plus

    - by polygenelubricants
    I've seen regex patterns that use explicitly numbered repetition instead of ?, * and +, i.e.: Explicit Shorthand (something){0,1} (something)? (something){1} (something) (something){0,} (something)* (something){1,} (something)+ The questions are: Are these two forms identical? What if you add possessive/reluctant modifiers? If they are identical, which one is more idiomatic? More readable? Simply "better"?

    Read the article

  • Java: repetition, overuse -- problem?

    - by HH
    I try to be as minimalist as possible. Repetition is a problem. I hate it. When is it really a problem? what is static-overuse? what is field-method overuse? what is class-overuse? are there more types of overuse? Problem A: when it is too much to use of static? private static class Data { private static String fileContent; private static SizeSequence lineMap; private static File fileThing; private static char type; private static boolean binary; private static String name; private static String path; } private static class Print { //<1st LINE, LEFT_SIDE, 2nd LINE, RIGHT_SIDE> private Integer[] printPositions=new Integer[4]; private static String fingerPrint; private static String formatPrint; } Problem B: when it is too much to get field data with private methods? public Stack<Integer> getPositions(){return positions;} public Integer[] getPrintPositions(){return printPositions;} private Stack<String> getPrintViews(){return printViews;} private Stack<String> getPrintViewsPerFile(){return printViewsPerFile;} public String getPrintView(){return printView;} public String getFingerPrint(){return fingerPrint;} public String getFormatPrint(){return formatPrint;} public String getFileContent(){return fileContent;} public SizeSequence getLineMap(){return lineMap;} public File getFile(){return fileThing;} public boolean getBinary(){return binary;} public char getType(){return type;} public String getPath(){return path;} public FileObject getData(){return fObj;} public String getSearchTerm(){return searchTerm;} Related interface overuse overuse of static in a Game

    Read the article

  • Java: repetition, overuse -- ?

    - by HH
    I try to be as minimalist as possible. Repetition is a problem. I hate it. When is it really a problem? what is static-overuse? what is field-method overuse? what is class-overuse? are there more types of overuse? Problem A: when it is too much to use of static? private static class Data { private static String fileContent; private static SizeSequence lineMap; private static File fileThing; private static char type; private static boolean binary; private static String name; private static String path; } private static class Print { //<1st LINE, LEFT_SIDE, 2nd LINE, RIGHT_SIDE> private Integer[] printPositions=new Integer[4]; private static String fingerPrint; private static String formatPrint; } Problem B: when it is too much to get field data with private methods? public Stack<Integer> getPositions(){return positions;} public Integer[] getPrintPositions(){return printPositions;} private Stack<String> getPrintViews(){return printViews;} private Stack<String> getPrintViewsPerFile(){return printViewsPerFile;} public String getPrintView(){return printView;} public String getFingerPrint(){return fingerPrint;} public String getFormatPrint(){return formatPrint;} public String getFileContent(){return fileContent;} public SizeSequence getLineMap(){return lineMap;} public File getFile(){return fileThing;} public boolean getBinary(){return binary;} public char getType(){return type;} public String getPath(){return path;} public FileObject getData(){return fObj;} public String getSearchTerm(){return searchTerm;} Related interface overuse

    Read the article

  • Avoid Code Repetition in Condition Statements

    - by Ethosik
    I have been programming for over 15 years now. I consider myself a very good programmer, but I understand (like all of us) there are things that I need to work on. One of these things is code repetition when dealing with conditions. I will give a generic sample: if(condition1) { //perform some logic if(condition2) { //perform some logic if(condition3) { //Perform logic } else { //MethodA(param) } } else { //MethodA(param) } } else { //MethodA() } Now, I cannot make it easy by doing the following: if(condition1 && condition2) { } else { } I cannot do this since I need to perform some logic if condition1 is true and before I test condition2. Is there a way to structure if...else blocks to where if you need to call a method in each else blocks, you are not repeating yourself?

    Read the article

  • Sanitize a string with non-alphanum repetition

    - by Toto
    I need to sanitize article titles when (creative) users try to "attract attention" with some non-alphanum repetition. Exemples: Buy my product !!!!!!!!!!!!!!!!!!!!!!!! Buy my product !? !? !? !? !? !? Buy my product !!!!!!!!!.......!!!!!!!! Buy my product <----------- Some acceptable solution would be to reduce the repetition of non-alphanum to 2. So I would get: Buy my product !! Buy my product !? !? Buy my product !!..!! Buy my product <-- This solution did not work that well: preg_replace('/(\W{2,})(?=\1+)/', '', $title) Any idea how to do it in PHP with regex? Other better solution is also welcomed (I cannot strip all the non-alphanum characters as they can make sense). Edit: the objective is only to avoid most common issues. The other creative cases will be sanitized manually or sanitized with an other regex.

    Read the article

  • Nested RDP and ILO/VMWare console sessions, latency and keystroke repetition

    - by ewwhite
    I'm working on a remote server installation entirely through ILO. Due to the software application and environment, my access is restricted to a Windows server that I must access through RDP. Going from that system to the target server is accomplished via HP ILO2 or ILO3. I'm trying to run a CentOS installation in an environment where I can't use a kickstart. I'm doing this via text mode, but the keystrokes are repeating randomly and it's difficult to select the proper installation options. For example: ks=http://all.yourbase.org/kickstart/ks.cfg ends up looking like: ks====httttttp://allll..yourbaseee.....org/kicksstart/ks.cccfg I'm doing this using Microsoft's native RDP client (on Mac and Windows). I've also noticed this before when running installations or doing remote work in nested sessions. Same for typing into a VMWare console in some cases. Is there a nice fix for this, or it it simply a function of the protocol(s)?

    Read the article

  • How to avoid code repetition initializing final properties?

    - by Hernán Eche
    public class Code{ //many properties //... final String NEWLINE;// ohh a final property! void creation() //this method is for avoid repetition of code { //final initialization can't be put here =( Source= new StringBuffer(); //many other commons new's .. //... } Code() { NEWLINE = System.getProperty("line.separator"); creation(); } Code(String name, int numberr) { NEWLINE = System.getProperty("line.separator"); creation(); name=new Someting(name); number = new Magic(number); } }

    Read the article

  • ArrayList without repetition

    - by tuxou
    Hi i'm using arraylist in java and i need to add integers during 10 iteration (integer is got randomly from an array of integers named arrint) without any repetion: for (int i =0; i<10; ++i) array.add(integer); and then add in the same array 20 other integers for the same array of integer(arrint) during 20 iteration without repetion for (int i =0; i<10; ++i) array.add(integer); but repetition is permited between the 10 first integers and the 20 integers thank you

    Read the article

  • Spaced repetition (SRS) for learning

    - by Fredrik Johansson
    A client has asked me to add a simple spaced repeition algorithm (SRS) for an onlinebased learning site. But before throwing my self into it, I'd like to discuss it with the community. Basically the site asks the user a bunch of questions (by automatically selecting say 10 out of 100 total questions from a database), and the user gives either a correct or incorrect answer. The users result are then stored in a database, for instance: userid questionid correctlyanswered dateanswered 1 123 0 (no) 2010-01-01 10:00 1 124 1 (yes) 2010-01-01 11:00 1 125 1 (yes) 2010-01-01 12:00 Now, to maximize a users ability to learn all answers, I should be able to apply an SRS algorithm so that a user, next time he takes the quiz, receives questions incorrectly answered more often; than questions answered correctly. Also, questions that are previously answered incorrectly, but recently often answered correctly should occur less often. Have anyone implemented something like this before? Any tips or suggestions? Theese are the best links I've found: http://en.wikipedia.org/wiki/Spaced_repetition http://www.mnemosyne-proj.org/principles.php http://www.supermemo.com/english/ol/sm2.htm

    Read the article

  • Reducing Code Repetition: Calling functions with slightly different signatures

    - by Brian
    Suppose I have two functions which look like this: public static void myFunction1(int a, int b, int c, string d) { //dostuff someoneelsesfunction(c,d); //dostuff2 } public static void myFunction2(int a, int b, int c, Stream d) { //dostuff someoneelsesfunction(c,d); //dostuff2 } What would be a good way to avoid repeated dostuff? Ideas I've thought of, but don't like: I could make d an object and cast at runtype based on type, but this strikes me as not being ideal; it removes a type check which was previously happening at compile time. I could also write a private helper class that takes an object and write both signatures as public functions. I could replace dostuff and dostuff2 with delegates or function calls or something.

    Read the article

  • Help me reduce code repetition in a simple jQuery function

    - by user339876
    I have built a carousel using the jQuery cycle plugin. I have 4 links that jump to relevent slides. Right now I have a chunk of code for each link. I am trying to create a single multi-purpose function. $('#features-slide0').click(function() { $('#features-slides').cycle(0); return false; }); $('#features-slide1').click(function() { $('#features-slides').cycle(1); return false; }); $('#features-slide2').click(function() { $('#features-slides').cycle(2); return false; }); $('#features-slide3').click(function() { $('#features-slides').cycle(3); return false; }); I have a rel value on each link that carries the number of the slide. How can I use that to create a single block of code that takes care of the link jump?

    Read the article

  • SQL query to select distinct record with 2 or more repetition in another field

    - by kyohiros
    So I have this table of book orders, it contains 2 columns, one is the order ID(primary key) and another is the ID of the book that the customer ordered. For example: | OrderID | BookID | | 0001 | B002 | | 0002 | B005 | | 0003 | B002 | | 0004 | B003 | | 0005 | B005 | | 0006 | B002 | | 0007 | B002 | What I want is to get the IDs of the books that got 2 or more purchases/orders, for example if I run the SQL query against the above data, I would get this as the result: | BookID | | B002 | | B005 | I don't know if this can be archived in SQL or I have to built a simpler statement and repetitive run the query against all the records in another language. I need some help and thanks for reading my question.

    Read the article

  • Mysql Limit column value repetition N times

    - by Paper-bat
    Hi at all, is my first question here, so be patient ^^ I'll go directly to problem, I have two table Customer (idCustomer, ecc.. ecc..) Comment (idCustomer, idComment, ecc.. ecc..) obviosly the two table are joined togheter, for example SELECT * FROM Comment AS co JOIN Customer AS cu ON cu.idCustomer = co.idCustomer With this I select all comment from that table associated with is Customer, but now I wanna limit the number of Comment by 2 max Comment per Customer. The first thing I see is to use 'GROUP BY cu.idCustomer' but it limit only 1 Comment per Customer, but I wanna 2 Comment per Customer.. how now to proceed?

    Read the article

  • Avoiding repetition with libraries that use a setup + execute model

    - by lijie
    Some libraries offer the ability to separate setup and execution, esp if the setup portion has undesirable characteristics such as unbounded latency. If the program needs to have this reflected in its structure, then it is natural to have: void setupXXX(...); // which calls the setup stuff void doXXX(...); // which calls the execute stuff The problem with this is that the structure of setupXXX and doXXX is going to be quite similar (at least textually -- control flow will prob be more complex in doXXX). Wondering if there are any ways to avoid this. Example: Let's say we're doing signal processing: filtering with a known kernel in the frequency domain. so, setupXXX and doXXX would probably be something like... void doFilter(FilterStuff *c) { for (int i = 0; i < c->N; ++i) { doFFT(c->x[i], c->fft_forward_setup, c->tmp); doMultiplyVector(c->tmp, c->filter); doFFT(c->tmp, c->fft_inverse_setup, c->x[i]); } } void setupFilter(FilterStuff *c) { setupFFT(..., &(c->fft_forward_setup)); // assign the kernel to c->filter ... setupFFT(..., &(c->fft_inverse_setup)); }

    Read the article

  • Regular Expression repetition of class

    - by codersarepeople
    I am trying to figure out a regular expression for the following: <tr class="A">.*</tr><tr class="(B|C)">.*</tr> Now The second tr class will repeat an unknown number of times, with something unknown in between repetitions, but simply putting it in parentheses and added a plus doesn't work. Here's the PHP code that didn't work: $pattern = '/<tr\ class=\"A\">.*(<tr\ class=\"(B|C)\">.*<\/tr>.*)+/'; preg_match_all($pattern,$playerHtml,$scores); But it only returns the first Here's an example of something that should match: <tr class="A">blah</tr>blah <tr class="B">blah</tr>blah <tr class="B">blah</tr>blah <tr class="C">blah</tr> This only matches blahblahblah

    Read the article

  • Clojure: find repetition

    - by demi
    Let we have a list of integers: 1, 2, 5, 13, 6, 5, 7 and I want to find the first number has a duplicate before it and return a vector of two indices, In my sample, it's 5 at [2, 5]. What I did so far is loop, but can I do it more elegant, short way? (defn get-cycle [xs] (loop [[x & xs_rest] xs, indices {}, i 0] (if (nil? x) [0 i] ; Sequence is over before we found a duplicate. (if-let [x_index (indices x)] [x_index i] (recur xs_rest (assoc indices x i) (inc i)))))) No need to return number itself, because I can get it by index and, second, it may be not always there.

    Read the article

  • assign member based on string value

    - by Aperion
    I need start off with code because I am not sure what terminology to use. Lets say I have the following code: class Node { public: void Parse(rapidxml::xml_node<> *node) { for (rapidxml::xml_attribute<> *attr = node->first_attribute(); attr; attr = attr->next_attribute()) { std::stringstream converter; converter << attr->value(); if( !strcmp(attr->name(), "x") ) converter >> x; else if( !strcmp(attr->name(),"y") ) converter >> y; else if( !strcmp(attr->name(), "z") ) converter >> z; } } private: float x; float y; float z; }; What I can't stand is the repetition of if( !strcmp(attr-name(), "x") ) converter x; I feel that this is error prone and monotonous, but I cannot think of another way to map a string value to a member assignment. What are some other approaches one can take to avoid code such as this? The only other possible alternative I could think of was to use a hashmap, but that runs into problems with callbacks This is the best I could up with but it's not as flexible as I'd like: class Node { Node() : x(0.0f), y(0.0f), z(0.0f) { assignmentMap["x"] = &x; assignmentMap["y"] = &y; assignmentMap["z"] = &z; } public: void Parse(rapidxml::xml_node<> *node) { for (rapidxml::xml_attribute<> *attr = node->first_attribute(); attr; attr = attr->next_attribute()) { if( !attr->name() ) continue; std::stringstream converter; converter << attr->value(); converter >> *assignmentMap[attr->name()]; } } private: float x; float y; float z; std::map<std::string, float*> assignmentMap; };

    Read the article

  • Python: How to display the calculated MD5 value in my browser?

    - by brilliant
    Hello, I was given this Python code that would calculate an MD5 value for any phrase: import md5 md5.new("Nobody inspects the spammish repetition").digest() (The phrase here is: "Nobody inspects the spammish repetition") What I want to do is display this value in my browser. How do I do it in Python? I tried all these variants, none of them worked: import md5 show = md5.new("Nobody inspects the spammish repetition").digest() print show import md5 print md5.new("Nobody inspects the spammish repetition").digest() import md5 md5.new("Nobody inspects the spammish repetition").digest() print md5 import md5 md5.new("Nobody inspects the spammish repetition").digest() print md5.new

    Read the article

  • Sequence reduction in R

    - by drknexus
    Assume you have a vector like so: v <- c(1,1,1,2,2,2,2,1,1,3,3,3,3) How can it be best reduced to a data.frame like this? v.df <- data.frame(value=c(1,2,1,3),repetitions=c(3,4,2,4)) In a procedural language I might just iterate through a loop and build the data.frame as I go, but with a large dataset in R such an approach is inefficient. Any advice?

    Read the article

  • Repeating procedure for every item in class

    - by Hendriksen123
    Data.XX.NewValue := Data.XX.SavedValue; Data.XX.OldValue := Data.XX.SavedValue; I need to do the above a large number of times, where XX represents the value in the class. Pretending there were 3 items in the list: Tim, Bob, Steve. Is there any way to do the above for all three people without typing out the above code three times? (Data is a class containing a number of Objects, each type TList, which contain OldValue, NewValue and SavedValue)

    Read the article

1 2 3 4 5 6 7  | Next Page >