I'm calling this function to load a TreeView with a list of the directories on the disk.
private void LoadDirectories(string currentPath, TreeNodeCollection nodes)
{
DirectoryInfo directoryInfo = new DirectoryInfo(currentPath);
DirectoryInfo[] directories = directoryInfo.GetDirectories();
foreach (DirectoryInfo dir in direc...
Playing with Erlang, I've got a process-looping function like:
process_loop(...A long list of parameters here...) ->
receive
...Message processing logic involving the function parameters...
end,
process_loop(...Same long list of parameters...)
end.
It looks quite ugly, so I tried a refactoring like that:
process_l...
Hi All,
I have as input a list of tuples (child, parent).
Given that a child only have one parent.
I would like for every child to build an ordered ancestors list.
Any tip ?
input would be like : [('3', '4'), ('1', '2'), ('2', '3')]
output would be like:
1, [2, 3, 4]
2, [3, 4]
3, [4]
4, [None]
...
Let's say we have a simple recursion like.
int x(int a){
if(a<10)
x(a+1);
else
!STOP!
b++;
return b;
}
Globaly:
int b=0;
In main we could have something like this:
int p=x(1);
Is there any way to stop the recursion so that the p will be 0, this means that "b++" will never be executed.
I'll be grateful ...
I need to be able to store a large list of ordered items in the DB. So far that's straight-forward:
ID Position OtherFields
1 45 ...
2 4736 ...
3 514 ...
...
In queries, I always need to get just a few items (filtered based on OtherFields) but in the correct order. Easy as well, putting an index on Position...
Hi!
Is Recoursive column grouping possible for tablix in RS2008?
If yes, please provided related link
...
I really dig the idea of using a recursice function to build my site menus but I am having a problem and have been banging my head for ages now.
I need my menu function to return a nested list but I dont want non-active irelevent elements of the tree to be displayed.
Details. I have a MySql database with a table called menu_items that s...
I'm looking for ideas for fast and effective way to walk through folders bottom-up using C#/.NET 3.5
for example:
-0
--1
---12
--2
---21
---22
---23
first walk though: 12,21,22,23
then: 1,2
Thanks
...
How do I implement mutually recursive classes in C++? Something like:
/*
* Recursion.h
*
*/
#ifndef RECURSION_H_
#define RECURSION_H_
class Class1
{
Class2* Class2_ptr;
public:
void Class1_method()
{
//...
(*Class2_ptr).Class2_method();
//...
}
};
class Class2
{
Class1* Class1_ptr;
public:
void C...
I am writing a permutation function that generate all permutations of a list in Python. My question is why this works:
def permute(inputData, outputSoFar):
for elem in inputData:
if elem not in outputSoFar:
outputSoFar.append(elem)
if len(outputSoFar) == len(inputData):
print outputSoF...
Is it possible to output the following HTML unordered list using recursion.
<ul>
<li>1
<ul>
<li>5
<ul>
<li>8</li>
<li>9</li>
</ul>
</li>
<li>6</li>
</ul>
</li>
<li>2</li>
<li>3</li>
<li>4</li>
...
Alternate Title: How to redirect on session timeout
FINAL SOLUTION: Credit to: Robin Day (Although I tested Ben's solution and it also works and the other two solutions are also both good solutions)
I got rid of the basepage that I had originally.
Put this in the Session_Start of Global.asax
void Session_Start(object sender, EventArg...
writing a recursive string reverse function out of curiosity, but having a bit of problem with XOR there. The whole point of this function, is to not use iterator, which is why it is a recursive function. this is not homework, just curiosity.
private static char[] ReverseNL(char[] arr, int index)
{
var len = arr.Length;...
I want to generate a random string of about 5 characters long. I can create it ok, but I'm having trouble checking if it exists in an array (or database in real situation) and creating a new one if it does.
I use a function like this to generate the string:
function rand_string(){
return substr(md5(microtime()), 0, 5);
}
But them...
I get the following error when I try to execute a particular recursive CTE:
Msg 240, Level 16, State 1, Line 8
Types don't match between the anchor and the recursive part in column "data_list" of recursive query "CTE".
This is nonsense. Each field is explicitly cast to VARCHAR(MAX).
Please help me. I've read many answers to this prob...
I have the following table:
id | parent_id | quantity
-------------------------
1 | null | 5
2 | null | 3
3 | 2 | 10
4 | 2 | 15
5 | 3 | 2
6 | 5 | 4
7 | 1 | 9
Now I need a stored procedure in mysql that calles itself recursivly and returns the computed quantity.
For example the i...
We're using an application build using Weblogic Workshop 10.3 and running on weblogic server 10.3. I'm trying to display a tree of data using recursive calls to a jsp page using <jsp:include>. The problem I'm having is that after about 3-4 layers deep the page doesn't get rendered anymore. Log statements around the JSP include show th...
Hi,
I'm not particularly accustomed to generating complex SQL queries and am having difficulty in mixing my understanding of procedural languages and of set-based operations in
devising a recursive query for network traversal. I wish to find the set of edges that lie 'upstream' of a particular node through conducting a depth first sear...
I've adapted this from an example that I found on the 'net...
function ratio($a, $b) {
$_a = $a;
$_b = $b;
while ($_b != 0) {
$remainder = $_a % $_b;
$_a = $_b;
$_b = $remainder;
}
$gcd = abs($_a);
return ($a / $gcd) . ':' . ($b / $gcd);
}
echo ratio(9, 3); // 3:1
Now I want it...
As an exercise, I've been trying out various ways of generating all permutations of a list in Python -- recursive, non-recursive... -- and comparing the performance with itertools.permutations(). But I'm having trouble with the generator version of the recursive method, which doesn't finish cleanly with a StopIteration exception, but ins...