Search Results

Search found 1171 results on 47 pages for 'recursive cte'.

Page 7/47 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • break up recursive function in php

    - by Mike
    What is the best way to break up a recursive function that is using a ton of resources For example: function do_a_lot(){ //a lot of code and processing is done here //it takes a lot of execution time if($true){ //if true we have to do all of that processing again do_a_lot(); } } Is there anyway to make the server only have to take the brunt of the first execution and then break up the recursion into separate processes? Or am I dreaming?

    Read the article

  • Java keep printing a new line in my recursive method

    - by Abra Grace Libretto White
    I am trying to write a recursive method to print n number of asteriks in a line and create a new line at the end. So, TriangleOps.line(5); would print ***** This is the code I wrote: public static void line (int n){ if(n>0){ System.out.println("*"); line(n-1); }} instead it prints * * * * * with a lot of space at the end. Can anyone tell me how to remove the line breaks?

    Read the article

  • Cache updates when migrating DNS from one provider to another

    - by JohnCC
    This may be a Windows DNS specific question or a general DNS best practice question - I'm not sure! We migrated our 3rd party DNS provision from provider A to provider B. I noticed that our internal recursive windows DNS servers still had NS records cached for our domains pointing to provider A's servers, even though I changed the nameservers with our registrar several days ago, and even though selecting the properties of the cached records showed a TTL of 1 day. After 24 hours when the NS records in this cache have expired, will the DNS server go back to the TLD server for an update on the authority, or will it go by preference to dns1.providera.com since that is what it has cached? In this case I arranged to leave Provider A's servers up for a week to allow changes to propagate, so dns1.providera.com is still active and would still provide NS and SOA records that said that dns1.providera.com. was in charge of this domain. Given this fact, would the Windows DNS server ever go back to the TLD and pick up the authority changes, or would it just assume all was well and renew timestamps on its cached NS records? I wonder what would be the best approach to ensuring that caches pick this up. Should I:- (1) Leave Provider A's servers in place and active and wait for caches to catch up ... basically what we're doing now which seems to have issues - perhaps specifically for Windows servers, or perhaps more widely. (2) Leave Provider A's servers in place but change the NS and/or SOA information they provide to tell caches that new servers are in charge. (3) Remove Provider A's servers after 2*TTL to force remaining caches to update. The issue with (2) is that on Provider A's system I can't seem to change the NS or SOA information to anything other than their servers. The issue with (3) is that I'm not sure how a DNS server would behave in this case. When it couldn't reach the cached name servers, would it flush its cache and try a full recursive lookup, or would it just return an error, forcing the user to clear the cache manually? Thanks in advance!

    Read the article

  • Tail-recursive pow() algorithm with memoization?

    - by Dan
    I'm looking for an algorithm to compute pow() that's tail-recursive and uses memoization to speed up repeated calculations. Performance isn't an issue; this is mostly an intellectual exercise - I spent a train ride coming up with all the different pow() implementations I could, but was unable to come up with one that I was happy with that had these two properties. My best shot was the following: def calc_tailrec_mem(base, exp, cache_line={}, acc=1, ctr=0): if exp == 0: return 1 elif exp == 1: return acc * base elif exp in cache_line: val = acc * cache_line[exp] cache_line[exp + ctr] = val return val else: cache_line[ctr] = acc return calc_tailrec_mem(base, exp-1, cache_line, acc * base, ctr + 1) It works, but it doesn't memorize the results of all calculations - only those with exponents 1..exp/2 and exp.

    Read the article

  • recursive html2haml

    - by yaya3
    I have many html files in nested directories which I need to convert to Haml templates I've modified the following bash script from here - http://terrbear.org/?p=277 to modify html files and not erb but I still need to modify it to be recursive ... #!/bin/bash if [ -z "$1" ]; then wdir="." else wdir=$1 fi for f in $( ls $wdir/*.html ); do out="${f%}.haml" if [ -e $out ]; then echo "skipping $out; already exists" else echo "hamlifying $f" html2haml $f > $out fi done I've named this script h2h.sh and tried going for commands like h2h.sh `find . -type d` I'm getting no output in the terminal Thanks

    Read the article

  • Recursive mocking with Rhino-Mocks

    - by jaspernygaard
    Hi I'm trying to unittest several MVP implementations and can't quite figure out the best way to mock the view. I'll try to boil it down. The view IView consists e.g. of a property of type IControl. interface IView { IControl Control1 { get; } IControl Control2 { get; } } interface IControl { bool Enabled { get; set; } object Value { get; set; } } My question is whether there's a simple way to setup the property behavior for Enabled and Value on the IControl interface members on the IView interface - like recursive mocking a guess. I would rather not setup expectations for all my properties on the view (quite a few on each view). Thanks in advance

    Read the article

  • recursive function to get all the child categories

    - by user253530
    Here is what I'm trying to do: - i need a function that when passed as an argument an ID (for a category of things) will provide all the subcategories and the sub-sub categories and sub-sub-sub..etc. - i was thinking to use a recursive function since i don't know the number of subcategories their sub-subcategories and so on so here is what i've tried to do so far function categoryChild($id) { $s = "SELECT * FROM PLD_CATEGORY WHERE PARENT_ID = $id"; $r = mysql_query($s); if(mysql_num_rows($r) > 0) { while($row = mysql_fetch_array($r)) echo $row['ID'].",".categoryChild($row['ID']); } else { $row = mysql_fetch_array($r); return $row['ID']; } } If i use return instead of echo, i won't get the same result. I need some help in order to fix this or rewrite it from scratch

    Read the article

  • bash : recursive listing of all files problem

    - by Michael Mao
    Run a recursive listing of all the files in /var/log and redirect standard output to a file called lsout.txt in your home directory. Complete this question WITHOUT leaving your home directory. An: ls -R /var/log/ /home/bqiu/lsout.txt I reckon the above bash command is not correct. This is what I've got so far: $ ls -1R .: cal.sh cokemachine.sh dir sort test.sh ./dir: afile.txt file subdir ./dir/subdir: $ ls -R | sed s/^.*://g cal.sh cokemachine.sh dir sort test.sh afile.txt file subdir But this still leaves all directory/sub-directory names (dir and subdir), plus a couple of empty newlines How could I get the correct result without using Perl or awk? Preferably using only basic bash commands(this is just because Perl and awk is out of assessment scope)

    Read the article

  • Recursive FTP directory listing in shell/bash with a single session (using cURL or ftp)

    - by Timo
    I am writing a little shellscript that needs to go through all folders and files on an ftp server (recursively). So far everything works fine using cURL - but it's pretty slow, becuase cURL starts a new session for every command. So for 500 directories, cURL preforms 500 logins. Does anybody know, whether I can stay logged in using cURL (this would be my favourite solution) or how I can use ftp with only one session in a shell script? I know how to execute a set of ftp commands and retrieve the response, but for the recursive listing, it has to be a little more dynamic... Thanks for your help!

    Read the article

  • XQuery - problem with recursive function

    - by H4mm3rHead
    Hi all, Im new on this project and am going to write, what i thought was a simple thing. A recursive function that writes nested xml elements in x levels (denoted by a variable). So far I have come up with this, but keeps getting a compile error. Please note that i have to generate new xml , not query existing xml: xquery version "1.0"; declare function local:PrintTest($amount) { <test> { let $counter := 0 if ($counter <= $amount ) then local:PrintTest($counter) else return $counter := $counter +1 } </test> }; local:PrintPerson(3) My error is: File Untitled1.xquery: XQuery transformation failed XQuery Execution Error! Unexpected token - " ($counter <= $amount ) t" I never understood xquery, and cant quite see why this is not working (is it just me or are there amazingly few resources on the Internet concerning XQuery?)

    Read the article

  • Advanced control of recursive parser in scala

    - by Jeriho
    val uninterestingthings = ".".r val parser = "(?ui)(regexvalue)".r | (uninterestingthings~>parser) This recursive parser will try to parse "(?ui)(regexvalue)".r until the end of input. Is in scala a way to prohibit parsing when some defined number of characters were consumed by "uninterestingthings" ? UPD: I have one poor solution: object NonRecursiveParser extends RegexParsers with PackratParsers{ var max = -1 val maxInput2Consume = 25 def uninteresting:Regex ={ if(max<maxInput2Consume){ max+=1 ("."+"{0,"+max.toString+"}").r }else{ throw new Exception("I am tired") } } lazy val value = "itt".r def parser:Parser[Any] = (uninteresting~>value)|parser def parseQuery(input:String) = { try{ parse(parser, input) }catch{ case e:Exception => } } } Disadvantages: - not all members are lazy vals so PackratParser will have some time penalty - constructing regexps on every "uninteresting" method call - time penalty - using exception to control program - code style and time penalty

    Read the article

  • recursive function's summation in MATLAB

    - by lucky
    B=[1 1 1 1 1 1....1] % vector of length N elements Xk= sin(2*pi/16) i need to find function alpha(l,k) which is having two variables l and k and a condition given that alpha(l,0)=alpha(l,-1)=alpha(l,-2)......=alpha(l,-(N-1))=0 i.e no matter what value of l ,alpha = 0 for past values A= input('no of iterations'); % no. of iterations user want N=input('N values of alpha:') alpha1=[]; for k=0:A-1 l=0:N-1 % need 10 separate alpha values for every k, which goes from 0 to A-1 alpha(l,k)= Xk + summation( B(j)*alpha(l,k-j)) % as summation goes from j=1 to N alpha1=[alpha1 alpha] end; could anyone please help me to solve this recursive function, i am new to matlab. alpha

    Read the article

  • Recursive Function To Create Array

    - by mTuran
    Hi, i use kohana framework and i am trying to code recursive function to create category tree. My Categories Table id int(11) NO PRI NULL auto_increment name varchar(50) NO NULL parent_id int(11) NO NULL projects_count int(11) NO NULL My Example Which Is Not Work public static function category_list($parent_id = 0) { $result = Database::instance()->query(' SELECT name, projects_count FROM project_categories WHERE parent_id = ?', array($parent_id) ); $project_categories = array(); foreach($result as $row) { $project_categories[] = $row; Project_Categories_Model::factory()->category_list($parent_id + 1); } return $project_categories; }

    Read the article

  • recursive find in emacs?

    - by Stephen
    Is there a recursive find function for a find in emacs? I thought the 'nix "find" was implemented in eshell but perhaps not (I've been using it on OS X but it must have been calling FreeBSD's "find")... I know of rgrep, find-grep, grep-find, in emacs, but I don't actually need the grepping part. Perhaps it's a feature in one of dired's functions (though I didn't find it)? Using windows and I miss some 'nix utilities... thought emacs 23.2 might fill in for me.

    Read the article

  • CakePhp: model recursive associations and find

    - by Petecocoon
    Hello to everybody! I've some trouble with a find() on a model on CakePhp. I have three model relationed in this way: Project(some_fields, item_id) ------belongsTo----- Item(some_fields, item_id) ------belongsTo----- User(some_fields campi, nickname) I need to do a find() and retrieve all fields from project, a field from Item and the nickname field from User. This is my code: $this->set('projects', $this->Project->find('all', array('recursive' => 2))); but my output doesn't contains the user object. I've tried with Containable behaviour but the output is the same. What is broken? Many many Thanks Peter

    Read the article

  • Recursive compilation using gcc

    - by curiousexplorer
    I am using the gcc compiler. My project source tree looks like somewhat like this test$~: tree . . |-- folder | |-- hello.cpp | `-- hello.h `-- main.cpp 1 directory, 3 files test$~: The file main.cpp contains the main() function and all the functions invoked by main.cpp lie in the directory named folder So far in all my little projects I never had to put some source code under a sub-directory. What I am looking for, in short, is some gcc command for recursive compilation in sub-directories and their subdirectories and so on... This command should be invoked from the home directory of the code project.

    Read the article

  • Python: Pickling highly-recursive objects without using `setrecursionlimit`

    - by cool-RR
    I've been getting RuntimeError: maximum recursion depth exceeded when trying to pickle a highly-recursive tree object. Much like this asker here. He solved his problem by setting the recursion limit higher with sys.setrecursionlimit. But I don't want to do that: I think that's more of a workaround than a solution. Because I want to be able to pickle my trees even if they have 10,000 nodes in them. (It currently fails at around 200.) (Also, every platform's true recursion limit is different, and I would really like to avoid opening this can of worms.) Is there any way to solve this at the fundamental level? If only the pickle module would pickle using a loop instead of recursion, I wouldn't have had this problem. Maybe someone has an idea how I can cause something like this to happen, without rewriting the pickle module? Any other idea how I can solve this problem will be appreciated.

    Read the article

  • 'Recursive' LINQ calls

    - by Sir Psycho
    Hi, I'm trying to build an XML tree of some data with a parent child relationship, but in the same table. The two fields of importance are CompetitionID ParentCompetitionID Some data might be CompetitionID=1, ParentCompetitionID=null CompetitionID=2, ParentCompetitionID=1 CompetitionID=3, ParentCompetitionID=1 The broken query I have simply displays results in a flat format. Seeing that I'm working with XML, some sort of recursive functionality is required. I can do this using recursion, but would like to see the linq version. Any help appreciated. var results = from c1 in comps select new { c.CompetitionID, SubComps= from sc in comps.Where (c2 => c2.CompetitionID == c1.CompetitionID) select sc };

    Read the article

  • Specify fields in a recursive find with cakephp

    - by Razor Storm
    Suppose I have a table Recipe that hasmany ingredients. I do a recursive find to grab recipes with their associated ingredients: $this->Recipe->find('all', array('fields' => array('id','title','description'))); Here I can use the 'fields' attribute to specify that I only want it to return id, title, and description. However, despite this, cakephp still returns ALL columns from the ingredients table. How do I tell cakephp that I only want ingredient table's id and name fields? btw ingredient model is "Ingredient" and the table is ingredients, and the aggregation table is recipes_ingredients.

    Read the article

  • C: Recursive function for inverting an int

    - by Jorge
    I had this problem on an exam yesterday. I couldn't resolve it so you can imagine the result... Make a recursive function: int invertint( int num) that will receive an integer and return it but inverted, example: 321 would return as 123 I wrote this: int invertint( int num ) { int rest = num % 10; int div = num / 10; if( div == 0 ) { return( rest ); } return( rest * 10 + invert( div ) ) } Worked for 2 digits numbers but not for 3 digits or more. Since 321 would return 1 * 10 + 23 in the last stage. Thanks a lot! PS: Is there a way to understand these kind of recursion problems in a faster manner or it's up to imagination of one self?

    Read the article

  • Java-Recursion: When does statements after a recursive method call executes

    - by Ruru Morlano
    When are statements after the method call itself going to execute? private void inorderHelper(TreeNode node) { if ( node==null ) return; inorderHelper(node.leftNode); System.out.printf("%d", node.data); inorderHelper(node.rigthNode); } All I can see is that the line of codes inorderHelper(node.leftNode) will continue to iterate until node == null and the method terminates immediately before node.data is printed. I think that I didn't get well recursion but all examples I can find doesn't have statements after the recursive call. All I want to know is when are statements like System.out.printf("%d",node.data) going to execute before the method return?

    Read the article

  • Segmentation fault C++ in recursive function

    - by user69514
    Why do I get a segmentation fault in my recursive function. It happens every time i call it when a value greater than 4 as a parameter #include <iostream> #include <limits> using namespace std; int printSeries(int n){ if(n==1){ return 1; } else if( n==2){ return 2; } else if( n==3){ return 3; } else if( n==4){ return printSeries(1) + printSeries(2) + printSeries(3); } else{ return printSeries(n-3) + printSeries((n-2) + printSeries(n-1)); } } int main(){ //double infinity = numeric_limits<double>::max(); for(int i=1; i<=10; i++){ cout << printSeries(i) << endl; } return 0; }

    Read the article

  • Write a recursive function in C that converts a number into a string

    - by user3501779
    I'm studying software engineering, and came across this exercise: it asks to write a recursive function in C language that receives a positive integer and an empty string, and "translates" the number into a string. Meaning that after calling the function, the string we sent would contain the number but as a string of its digits. I wrote this function, but when I tried printing the string, it did print the number I sent, but in reverse. This is the function: void strnum(int n, char *str) { if(n) { strnum(n/10, str+1); *str = n%10 + '0'; } } For example, I sent the number 123 on function call, and the output was 321 instead of 123. I also tried exchanging the two lines within the if statement, and it still does the same. I can't figure out what I did wrong. Can someone help please? NOTE: Use of while and for loop statements is not allowed for the exercise.

    Read the article

  • Recursive solution to finding patterns

    - by user2997162
    I was solving a problem on recursion which is to count the total number of consecutive 8's in a number. For example: input: 8801 output: 2 input: 801 output: 0 input: 888 output: 3 input: 88088018 output:4 I am unable to figure out the logic of passing the information to the next recursive call about whether the previous digit was an 8. I do not want the code but I need help with the logic. For an iterative solution, I could have used a flag variable, but in recursion how do I do the work which flag variable does in an iterative solution. Also, it is not a part of any assignment. This just came to my mind because I am trying to practice coding using recursion.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >