recursion

recursive stl map

I'm trying to make a tree of maps (or just have values of a map point to another map), but I'm not too sure how to approach this. I found a discussion about this: http://bytes.com/topic/c/answers/131310-how-build-recursive-map but I'm a little confused on what's going on there. For example, my key is a char, and my value is the next ma...

Recursive function via reference

I need to recursivly echo comments and their respective children from a Jelly collection in Kohana. I was wondering how I pass a variable to a function via reference. I assume it would be something like this: function recursive(&$array) { recursive(&$array); } But I am not quite sure. So is this correct or when I call the function...

JavaScript: Building a HTML table from a nested JSON

I have a problem building a HTML table from the following JSON [ { "size" : 167, "price" : 453400, "type" : "Neubau", "children" : false }, { "size" : 167, "price" : 453400, "type" : "Neubau", "children" : false }, { "size" : 167, "price" : 453400, "type" : "Neubau", ...

SQL: How to create view from a recursive query?

Question: I have a view which I want to derive from a recursive query. The query is of the same structure as this one here: http://forums.asp.net/t/1207101.aspx And represents a treeview as an ordered dataset. How can I create a view which does this: ;WITH Tree (ID, [NAME], PARENT_ID, Depth, Sort) AS ( SELECT ID, [NAME], PARENT_I...

How to find the longest path between two nodes in Lisp?

Hi, I need to program a Lisp function that finds the longest path between two nodes, without revisiting any nodes. Though, if the start and end node are the same, this node can be revisited. The function needs to be both recursive and depth-first-search. I've been trying to get at this for hours, and cannot come up with a solution. I kn...

Looking for a simple test for circular reference in a recursive model

I have a model that represents an assembly that is made up of components, components may (in their own right) also be assemblies. It looks a little like this: class Component < ActiveRecord::Base belongs_to :assembly, :class_name => "Component", :foreign_key => :assembly_id has_many :pieces, :class_name => "Component", :foreign_key...

Recursive directory list/analyze function doesn't seem to recurse right

I wrote what I thought was a straightforward Python script to traverse a given directory and tabulate all the file suffixes it finds. The output looks like this: OTUS-ASIO:face fish$ sufs >>> /Users/fish/Dropbox/ost2/face (total 194) === 1 1 - === css 16 ----- === ...

Is there a reason/setting that would prevent a Coldfusion server from running recursive functions

I am using Hostek.com, shared hosting, and can't seem to get a recursive function to run. ...

Is there a way to break out of event recursion in jQuery without using a global variable?

I have a form with 2 text inputs and 2 span controls. Normally, when textbox A is changed an event is fired to change span A, and when textbox B is changed, an event is fired to change span B. However, in one particualar case I would like a change either textbox A or textbox B to update both span A and B. I tried wiring the events up to...

recursively downloading files from webpage..

http://examples.oreilly.com/9780735615366/ I actually want to be able to have all these files in my disk. as u can see there are many folders each with different type of files. and u cannot download "the-folder" directly...only individual files ~ is there any way to automate process..? I will need regular expressions on urls to arr...

GNU Prolog - Recursion problem (easy?)

Ok, so i have this edu_less(hs,college). edu_less(college,masters). edu_less(masters,phd). I need to write a function to tell if something is than the other. The predicate is edu_le. So if i put edu_le(hs,phd). it should return yes. I came up with this. edu_le(A,B) :- A = B. edu_le(A,B) :- edu_less(A,B). edu_le(A,B) :- edu_less(A,...

Recursively look through properties of specific type

EDIT: It looks like their is no simpler way to do this. Given the size of the class structure, the foreach approach seems to be the easiest (and probably the best) way to achieve my goal. I leave the question opened just in case someone has a brilliant idea. :) Hi all, I have a list of classes with a structure similar to this: class...

How to handle recursion in views(mvc)?

Hello, I need to recursively iterate over an array in a view and was wondering what are some best practices for this type of situation? I'm trying to avoid building my desired html output in the controller or model. FYI I'm using the framework codeigniter. Thanks for the help! ...

What is wrong with this functions recursion? (setTimeout issue)

Hi guys, I am writing a marquee script because I do not like the fact that with most marquee scripts when the marquee reaches the last item (thinking using a ul, so last item is the last li), it waits till that item is off screen, and then resets the position of the ul, and starts the scrolling all over agian. My approach is to create ...

Search for a key in an array, recursivly

private function find($needle, $haystack) { foreach ($haystack as $name => $file) { if ($needle == $name) { return $file; } else if(is_array($file)) { //is folder return $this->find($needle, $file); //file is the new haystack } } return "did not find"; } Hey, t...

Recurrence Relation

Hi, everyone I have simple recurrence relation and I need to solve it in teta() terms. (n-1)^2 f(n) = (n-1)(n+1)f(n-1) + (n-3)(n+1)f(n-2) + (n(n-1))/2 That would be great if you can help me out. Thanks ...

Selection Sort - Stack Overflow

Hi I am trying to implement Selection Sort in vb.net using recursion. Problem is that I keep getting stackoverflow if the array I want to sort is 1000 elements. I can't find the problem. I don't know much about stack overflow or how to check it. From my research the problem could be infinite recursion but I check for that and exit the su...

Is this Fibonacci sequence function recursive?

Consider the following (Haskell) code: fib=0:1:zipWith (+) fib (tail fib) A coworker is trying to assert that this is not a recursive function because fib is simply a list that defines itself with itself and that is somehow different than a function that does the same. I think he's smoking crack. What do you think? ...

ifstream fails to open in recursive calls

hello. we are running into an odd issue when trying to parse an input file. the idea is that this file can include other files, which must be parsed as well. We are doing this recursively in a function defined as int parse_inp(const char* filename) The main file parses no problem, but recursive calls cannot open their file streams. ...

Recursive read of TCollection

Hi, I'm very bad with recursion, never used it before. I know the theory of it .. not that that helps :)) For my problem i have a structure of TCollection that contains TCollection and TCollectionItem etc .. I have to write a recursion function that will read all my TCollectionItems. Here is graphical view: TCollection->TCollectionItem...