recursion

Solve recurrence of form p[n,m]==p[n,m-2]+p[n-1,m-1]+p[n-2,m]

I'm trying to solve (find a closed-form solution to) this (Risk odds calculator) recurrence relation: p[n,m] == 2890/7776*p[n,m-2] + 2611/7776*p[n-1,m-1] + 2275/7776*p[n-2,m], p[n,1] == 855/1296 + 441/1296*p[n-1,1], p[3,m] == 295/1296*p[3,m-2] + 420/1296*p[2,m-1], p[2,m] == 55/216, p[1,m] == 0 Mathematica's RSolve function doesn't wor...

Haskell List Reversal Error

Hi guys, I'm writing a list reversal program for haskell. I've got the idea for the list reversal and that has lead to the following code: myreverse list1 | list1 == [] = list1 | otherwise = (myreverse(tail list1)):(head list1) Unfortunately the above code results in the following error: Occurs check: cannot construct the...

Function to create a tree of properties?

I am trying to create a List of properties for objects. I can create a list for basic objects just fine, but if I have a situation where type object A contains a property of type object B which contains a property of type object A.... well.. then I get infinite recursion. What I've done is added a static property to all of my objects ca...

Haskell Question on pattern matching

Hi everyone, I'm trying to write a function that takes in a list and returns true if it is in sorted order and false if not: So far what I have is: myordered [] = True myordered [x] = True myordered list1 | (head list1) <= (head (tail list1)) = myordered(tail list1) | otherwise = False Based on our ...

Selector being performed when trying to set UITextField text

Hi, i'm trying to clear a UITextField whenever the UIControlEventEditingChanged event is being performed. However, when I set the text to nothing, the UIControlEventEditingChanged event is being called again, and this is the way it keeps going. This is my code: - (void)updateText { //other code textfield.text = @""; //othe...

I need an array_keys_recursive()

$temp = array(); function show_keys($ar) { foreach ($ar as $k => $v ) { $temp[] = $k; if (is_array($ar[$k])) { show_keys ($ar[$k]); } } return $temp; } I tried using that function but it still only returns the first key. ...

Registry Search

I am trying to use C/C++ (Preferably C) to enumerate the entire Windows registry, I was using recursion to do this but I keep running into stack overflows, which i understand but im unable to think of anyway to do this without recusion. Advice on how to do this without recursion would be great, thx. ...

How to Limit The Depth of a Recursive Sub-Directory Search

I've got a function that currently grabs all folders and sub-folders to check the ACL's for a small tool I'm building but I'm pulling my hair out trying to figure out how to limit the depth that it can go to. For example you have a folder that goes 4 levels deep but I want to be able to only grab 3 levels of it for ACL's. Currently I h...

recursive array_diff()?

I'm looking for some tool to give me a recursive diff of two arrays. What I envision is a web page with two color-coded tree-structures. On each tree, green are parts of the array which match in both arrays, and red is for parts of each that don't match the other. Something like the output of dBug I have some code that gives me a nested...

When to use ArrayList over array in recursion

So I have this problem. I was trying to code a program to print all the valid possible arrangements of brackets i.e. for 3 brackets we can have ((())), (()()), ()()(), (())() etc. I have a working code public static void main(String[] args) { int number = 3; // No. of brackets int cn = number; int on = number; // open ...

javascript: recursive anonymous function?

Lets say I have a basic recursive function: function recur(data) { data = data+1; var nothing = function() { recur(data); } nothing(); } How could I do this if I have an anonymous function such as... (function(data){ data = data+1; var nothing = function() { //Something here that calls the func...

Getting NDepend to recurse through an input directory finding all assemblies/source across multiple projects

I am using a NAnt build script to call NDepend with the required command line arguments. <exec program="NDepend.Console.exe" basedir="${NDependPath}"> <arg line="${NDependProjectFilePath} /indirs ${NDependInDirs} /outdir ${NDependOutputDir}" /> </exec> But what I am looking for is to get NDepend to recurse through all subdirectorie...

moving of disc in tower of hanoi

Please explain to me the recursion process step by step using F7. I just can't correlate the return with flow of control. #include<stdio.h> #include<conio.h> void t_of_h(char, char, char, int); void main() { int n; clrscr(); printf("Enter no of DISC in Tower of Hanoi : "); scanf("%d",&n); printf("\nTower of Hano...

Finding out when Recursion involving Asynchronous operation finishes

Hi All, I have a recursive call which includes an asyn operation (file copy) .. I want to find out when the recursive call finishes (along with all asyn operations). private function copyInto(directoryToCopy:File, locationCopyingTo:File):void { var directory:Array = directoryToCopy.getDirectoryListing(); ...

Building a right angled triangle with recursion.

I have this homework which required to print asterick to make draw a triangle. When drawTriangle(0); * When drawTriangle(1); * ** When drawTriangle(2); * ** * * **** when drawTriangle(3); * ** * * **** * * ** ** * * * * ******** when drawTriangle(4); * **...

Recursive SQL to Find Critical Path?

Given these two tables: [dbo].[Task] [Id] [Duration] [ScheduledStart] int int Nullable DateTime [dbo].[TaskDependencies] [Id] [PredecessorTaskId] [TaskId] int FK_Task_Id FK_Task_Id I'm trying to find the latest end date of the Tasks immediate predecessors. For the Task table, ScheduledStart is nullab...

Need help speeding up this jQuery process

Hi, I've created the following process. Basically it loops through a gigantic unordered list with multiple level nested lists and creates a 2 level nested unordered list. It works well but is very slow in IE7. FireFox and Safari have no big problems with it. Not very good at jQuery I was wondering if I could speed up this by using bette...

AppleScript Processing Files in Folders recursively

Hi, I have a root folder and there are sub folders in it. It is generally one level only but it can be deeper. These folders will have different files including some .rar files. I want to create a recursive function which traverses the folders, check if the file is a rar file and open/extract it. The code is working to first level with ...

Boost Condition Variable Argument Error

Hello to all, i encounter an error in the code below. recursive_mutex m_RecurMutex; condition_variable cond; unique_lock<recursive_mutex> lock(m_RecurMutex); cond.wait(lock); // Error Here. What is the reason cause this error ? Thanks. ...

Recursive unordered list from the inside and out

I'm trying to build a treeview HtmlHelper that builds an unordered list from the inside and out and show the children of the current node and the children of each parent. Has anyone done anything like this before or can give me some hints how i should solve it? ...