recursion

recursive method calls

String url = getUrl(); try{ Connection con = getConnection(url, username, pwd); }catch(ConnectionException e){ cleanUpUrl(url); url = getUrl(); con = getConnection(url, username, pwd); } I've to do something like above. if I don't get Connection with one URL then I'll be trying with another URL. Likewise there are 10URLs which I'...

How can I recursively check an array of file include dependencies for other dependencies?

To explain my question, let me first point to this array: <?php $_depends = array( '/Scripting/jquery.hyponiqs/jquery.dropdown.js' => array( "/Scripting/jquery.externals/jquery.resize.js", "/Scripting/jquery.externals/jquery.topzindex.js", "/Scripting/jquery.externals/jquery.timers.js", "/Scripting/jq...

PHP dynamic URL writing to accommodate dynamic menu and paths

I'm trying to figure out what the best way to go about rewriting urls to accommodate not only a directory structure, but appended actions for a menu for a site I'm building in PHP. I have one page that dynamically loads content based on whatever "page" is being loaded. Includes are pulled based on what the page is. Right now that's tied...

Is there anything which can only be achieved by recursion?

I am not sure but I had heard of an algorithm which can only be achieved by recursion. Does anyone know of such thing? ...

UVa 3n+1 Case Recursive Stack Overflow

hi, im trying to solve this very first challange but i get stuck, i like fast program, so i decided to use recursive method not iteration unfortunately, when the input is a big integer (100000 > input > 1000000), its often crash so i debug it, and it shows stack overflow error please help me, i dont know what to do, ive tried to chang...

mysql recursive self join

create table test( container varchar(1), contained varchar(1) ); insert into test values('X','A'); insert into test values('X','B'); insert into test values('X','C'); insert into test values('Y','D'); insert into test values('Y','E'); insert into test values('Y','F'); insert into test values('A','P'); insert into test values('P','Q'); i...

C# - Finding the Boundaries of an Image (not the size)

Hello ! I'm developing an application to split an image grid equally and center the images (based on their similarity). So far, I could manage to fix a grid of images with small sizes, but whenever I try a larger "sprite" size (100x100, for instance), I get Stack Overflow error. Yes I'm using recursion, but whenever a pixel is checked,...

How to list all of the files in a directory and its subdirectories with php

I'm attempting to use a sample function on the PHP manual website (posted by a user). The function is supposed to return a nested array of all of the files and/or folders in a specified directory of your server. I'm just learning php, so I think it's more likely that I'm doing something wrong, and less likely that the function doesn't ...

Recursive Reflection of property values with LINQ?

I have a predicate builder that accepts a SearchInfo Class. For most cases this works great, but has problems if a user specifies a query on a property that has a deep object graph. For example, a list of possible properties: var names = new[] { "Action.Strategy.Objective.Goal.Identifier", "Action.Strategy.Objective.Identifier", "Actio...

ERLANG - Splitting Lists into sub list

Hi this is my first post here hope you all are well. So Im just starting erlang and I ran into a problem im not sure how to tackle yet. So I have a binary I am recieving in the form of <<56, 23, 67, 34, 45, 78, 01, 54, 67, 87, 45, 53, 01, 34, 56, 78>> My goal is to split it into a sub list (or binary if more efficient) based on t...

In a tree structure, how to name the tree, the nodes, the leaves?

Hello, this question is about best practices. I'm implementing a 3D interval Kd-Tree and, because of the recursive structure of the tree I would be tempted to create a unique class, KdTree to represent the tree itself, the nodes and the leaves. However: elements are contained only at leaves, some general tree parameters (such as the ma...

Trying to come up with a recursive function to expand a tree in Python

I have table that looks like this: id | parentid | name --------------------- 1 | 0 | parent1 --------------------- 2 | 0 | parent2 --------------------- 3 | 1 | child1 --------------------- 4 | 3 | subchild1 I'm now trying to come up with an efficient way to take that database data and create a Py...

Git Merge Recursive Ours - Command Syntax Example

What is the right format for a git merge with a strategy of recursive ours? (not to be confused with the git merge ours strategy) http://www.kernel.org/pub/software/scm/git/docs/git-merge.html I tried a bunch of ways and it doesn't seem to work. git merge foo -s recursive-ours // doesn't work git merge foo -s recursive ours // doesn...

How Can This Recursive Function Work?

I can't figure out how this works, to my mind, once it gets to the answer it doesn't do anything with it. Node* FindNode(Node *rootNode, int data) { if (!rootNode) return NULL; else { if (rootNode->data == data) return rootNode; else { FindNode(rootNode->left, data); FindNode(rootNode->right, data); } ...

Applying the Y-Combinator to a recursive function with two arguments in Clojure?

Doing the Y-Combinator for a single argument function such as factorial or fibonacci in Clojure is well documented: http://rosettacode.org/wiki/Y_combinator#Clojure My question is - how do you do it for a two argument function such as this getter for example? (Assumption here is that I want to solve this problem recursively and this n...

PHP - Return an array from a recursive function

Hi all, After two hours of head scratching and googling - i'm stuck! As per the title I'm trying to return an array that is built up as the function loops through. I want to only return the array variable on the else however it will not co-operate. It simply returns as blank away from the function, however within the else I can prin...

infinite loop in functional programming ?

I was wondering: can infinite loops be done in functional programming? example: when using the windows API to get windows messages, it is usually implemented in a loop. I know it is possible to make a function that will keep going into recursion indefinitely. I expect that this will result in a stack overflow. are infinite loop the...

Trying to get the path to a node with PHP & MySQL

Hello, I'm trying to build a breadcrumb here and I'm having some trouble doing it. The problem arises from the fact that I have to save category name (in two languages), slug and id. My categories table looks like this: CREATE TABLE `categories` ( `category_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `category_name` varchar(2...

Understanding Recursion (applying it on Bubble Sort)

Hello All, I am trying to figure out how to use recursion in programs. I understand how recursion works in classical examples like "factorial", but am not sure how to apply it on my own... I am starting out with converting an iterative bubble sort code into a recursive code... I have searched over the net for the same.... but am not a...

How do I recursively delete all files in a folder that begin with "._"?

As the title states, I'm trying to recursively delete all files in a folder that begin with ._. For each file on my site, there exists a file with the same exact name, but with ._ appended to it. How do I get rid of these pesky buggers? Thanks! ...