Search Results

Search found 1112 results on 45 pages for 'recursive'.

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

  • Base Case in a recursive method

    - by Shaza
    Hey all, About my question, I'm asking a theoretical question here about Base case or the halting case in a recursive method, what's its standards? I mean, is it standard not to have body in it, just a return statement? Is it always like the following: If(input operation value) return sth; Do you have different thoughts about it??

    Read the article

  • Traverse a XML using Recursive function

    - by Kaja
    How can I traverse (read all the nodes in order) a XML document using recursive functions in c#? What I want is to read all the nodes in xml (which has attributes) and print them in the same structure as xml (but without Node Localname) Thanks

    Read the article

  • Return NSString from a recursive function

    - by Dave
    Hi, I have a recursive function that is designed to take parse a tree and store all the values of the tree nodes in an NSString. Is the algorithm below correct? NSString* finalString = [self parseTree:rootNode string:@""]; -(NSString*)parseTree:(Node*)currentNode string:(NSMutableString*)myString { [myString appendText:currentNode.value]; for(int i=0;i<[currentNode.children length];i++){ return [self parseTree:[currentNode.children] objectAtIndex:i] string:myString]; } }

    Read the article

  • Recursive only 2 level records using common sql

    - by Tony
    I have an Employee table, it's a self-referencing table, with managerId refers to primary key empID. I want to find 2 level records by a given empId. For example: if given empId=5, if empId=5 has children records, display them, as well as the children in children records. You may also provide a recursive suggestion without level limitation. The database is SQL Server 2005.

    Read the article

  • 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 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

  • 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

  • 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

  • t-sql recursive query

    - by stackoverflowuser
    Based on an existing table I used CTE recursive query to come up with following data. But failing to apply it a level further. Data is as below id name parentid -------------------------- 1 project 0 2 structure 1 3 path_1 2 4 path_2 2 5 path_3 2 6 path_4 3 7 path_5 4 8 path_6 5 I want to recursively form full paths from the above data. Means the recursion will give the following output. FullPaths ------------- Project Project\Structure Project\Structure\Path_1 Project\Structure\Path_2 Project\Structure\Path_3 Project\Structure\Path_1\path_4 Project\Structure\Path_2\path_5 Project\Structure\Path_3\path_6 Thanks

    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 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 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

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