recursion

Building a new Dictionary out of an old one? Help with Dictionary recursion

I'm working with a large set of hierarchical taxonomic terms, where each term ("203") has a matching "term203" movie clip on the stage, and am having trouble getting a recursive function to return all of a given term's descendants. There is a main Dictionary() object with the following nested organization for each term: { [object Movie...

Towers of Hanoi with K pegs

The Towers of Hanoi problem is a classic problem for recursion. You are given 3 pegs with disks on one of them, and you must move all the disks from one peg to another, by following the given rules. You must also do this with the minimum number of moves. Here's a recursive algorithm that solves the problem: void Hanoi3(int nDisks, char...

Maximum stored procedure, function, trigger, or view nesting level exceeded in Visual Studio (ado.net) but not in SQL server.

I have a problem with a recursive SQL function. The original problem is that I've got a list of employees, each of them has various trainings. Each of these trainings has some pre requirements. For example to have your Class 1 drivers license you must have your Class 5. If I remove the Class 5 I need to check disable the Class 1. Now as...

Using linq to get list of web controls of certain type in a web page

Is there a way to use linq to get a list of textboxes in a web page regardless of their position in the tree hierarchy or containers. So instead of looping through the ControlCollection of each container to find the textboxes, do the same thing in linq, maybe in a single linq statement? ...

F#: Mutually recursive functions

Possible Duplicate: [F#] How to have two methods calling each other? Hello all, I Have a scenario where I have two functions that would benefit from being mutually recursive but I'm not really sure how to do this in F# My scenario is not as simple as the following code, but I'd like to get something similar to compile: let ...

Rspec: How to test recursion?

I'd like to test that a method is called recursively with a specific argument. My approach: class Recursable def rec(arg) rec(7) unless arg == 7 end end describe Recursable do it "should recurse" do r = Recursable.new('test') r.should_receive(:rec).with(0).ordered r.should_receive(:rec).with(7).ordered r.rec(...

T-SQL How to run procedure recursively ?

Hi, in my procedure, I try to run itself recursively when some conditions appear (I simplified the code just to find out how to do the recursion) Firstly I created the procedure with commented the BEGIN..END body, and then: alter PROCEDURE [dbo].[insert_new_customer_task] @TaskTypeID decimal, @TaskName nvarchar(1000), @...

Is it possible to write a recursive IEnumerable<T>

I have a class like: class Spline int ChildrenCount; Spline GetChild (int index) class SplineCollection : IEnumerable<Spline> Spline Master Is it possible to write a recursive IEnumerable for the SplineCollection where it will return all the children one by one? EDIT: So Master is the root Box, and the hierarchy of its c...

Python: Strange behaviour of recursive function with keyword arguments

Hi folks, I've written a small snippet that computes the path length of a given node (e.g. its distance to the root node): def node_depth(node, depth=0, colored_nodes=set()): """ Return the length of the path in the parse tree from C{node}'s position up to the root node. Effectively tests if C{node} is inside a circle a...

Recursion and setTimeout in JavaScript

I have a recursive function in my JavaScript file. It looks something like this: function process(node){ if(someCondition) return someValue; a = process(node.children); b = doSomething(a); return b; } The problem is that I want to display the state of the system to the HTML output on each step of this recursion...

F# Recursion termination

I have been reading alot about functional programming and f#. I have a snippet of code that I cannot understand. I am familiar with recursive programs but this particular code is bugging me open System let rec fact x = if x < 1 then 1 else x * fact (x - 1) fact 6 In this snippet of code there is no where in the code that ter...

Does CUDA support recursion?

Does CUDA support recursion? ...

Recursive MySQL query

My database schema looks like this: Table t1: id valA valB Table t2: id valA valB What I want to do, is, for a given set of rows in one of these tables, find rows in both tables that have the same valA or valB (comparing valA with valA and valB with valB, not valA with valB). Then, I want to look for rows with...

F# recursion inside type definition

Hey all, I am having some problems with trying to implement Automatic Differentiation in F#. I think the problem is down to the evaluation not being 'lazy'. Here is my code: type Diff = {d : double; df : Diff} static member (+) (x : Diff, y : Diff) = {d = x.d + y.d; df = x.df + y.df} static member (-) (x : Diff, y ...

How can I recursively delete folder with a specific name with PowerShell?

I can delete files with specific extensions in multiple folders with this: Get-childitem * -include *.scc -recurse | remove-item But I also need to delete folders with a specific name - in particular those that subversion creates (".svn" or "_svn") when you pull down files from a subversion repo. ...

Converting flat data from sql to List<Item>

First of all I'm sorry if you feel this question has been raised before, but I can't seem to wrap my mind around this one, although it's rly not the hardest thing to do.. Basically I have a query result from sql which holds several rows, existing out of : id, parentid, name, description, level level is the depth of the item viewed as...

Recursive Programming for Text Predictive text

I want to make a program that takes a set of numbers like 234, and at the moment, print out every combination of letters possible that are on a mobile phone keypad. (1 - nothing, 2 - abc, 3- def and so on) I currently have: import java.util.*; public class testCombo { static String str="217"; static ArrayList<String> list=new...

How Do You Predict A Non-Linear Script's Run Time?

I wrote this simple code in python to calculate a given number of primes. The question I want to ask is whether or not it's possible for me to write a script that calculates how long it will take, in terms of processor cycles, to execute this? If yes then how? primes = [2] pstep = 3 count = 1 def ifprime (a): """ Checking if the pass...

Recursive listing of all files matching a certain filetype in Groovy

I am trying to recursively list all files that match a particular file type in Groovy. The example at link text almost does it. However, it does not list the files in the root folder. Is there a way to modify this to list files in the root folder? Or, is there a different way to do it? TIA ...

How do I record loop iteration count and recursion depth in a reference variable that is an argument of the recursive function?

Say I have a recursive function that contains a loop. I want to count how many times the loop runs as well as at what depth in the recursion the count exists in. The trick is I want to store this in a reference variable that is a parameter of the recursive function. It will always have this reference variable to append to it. The referen...