recursion

JQuery append closing tag before data

Hi I am creating a Adobe Air application with jQuery support. However, the recursive function that I have closes the tag first and writes the data afterwards. My code is, function displayTodoItems(id) { id = parseInt(id) if(!id) $("#todoLists").empty(); var list = fetchTodoItems(id); if(list.data == null) return; var numRec...

A problem with the usage of recursive XML schema types

It is easy to define two elements with the same name like <any> in one XML schema and different permitted subelements. One should just declare two XSD types AnyType1 and AnyType2 as complexTypes which describes permitted subelements. Then one can declare element <any> in one context as <xs:element name="any" type="AnyType1" /> and as <xs...

C# WPF treeview filled with recursive built list<> add item at position

Hi I have a TreeView which is filled with a hierarchicaldatatemplate <TreeView Name="DokumentBrowser" ItemTemplate="{StaticResource HierachrTree}" <HierarchicalDataTemplate x:Key="HierachrTree" DataType="{x:Type src:Ordner}" ItemsSource="{Binding UnterOrdner}"> <TextBlock Text="{Binding OrdnerName}"/> ...

ASP.net convert SqlDataReader to tree

Given the simple data structure: ID | Category_Name | Parent_ID Example: 1 Cars 0 2 Boxes 0 3 Lamborghinis 1 4 Camper Vans 1 5 Big Boxes 2 6 Small Boxes 2 7 Cereal Boxes ...

Recursive array keys replacement

Hello, I have quite big recursive array with mixed numeric and string keys. Which is the fastest way to replace the numeric keys with string keys (prefix each numeric with item_)? eg. array('key_1' => 'val1', 2 => array( 3 => 'val3')); to array('key_1' => 'val1', 'item_2' => array('item_3' => 'val3')); I want the order of the it...

problem calling a php method from within itself

class styleFinder{ function styleFinder(){ } function getFilesNFolders($folder){ $this->folder = $folder ; if($this->folder==""){ $this->folder = '.'; } if ($handle = opendir($this->folder)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { ...

C# - How does one handle/catch StackOverFlowExceptions?

I don't need a lesson in switching from recursive to non-recursive means, I just want to know why we can't deal with this type of exception. Regardless, I'm using recursive functions on very large lists. I have written code to attempt to catch StackOverFlowExceptions: try { recursiveFxn(100000); } catch(Exception){} private void recu...

How to avoid recursive triggering of events in WPF?

I am having two WPF (from the standard set) widgets A and B. When I change some property of A it should be set on B, when it is change in B it should be set on A. Now I have this ugly recursion --> I change A, so code changes B, but since B is changed, it changes A, so it changes B... You have the picture. How to avoid this recursion t...

output of the programme

#include<stdio.h> void f(void) { int s = 0; s++; if(s == 10) return; f(); printf("%d ", s); } int main(void) { f(); } what is the output of the programme!?? i m segmentation fault ...what is it? ...

How does one make a point to point "bolt" of lightning using perlin noise or other algorithm?

Every implementation I've come across of perlin noise generation has been for the generation of 2D terrain, etc. I cannot find a decent example of point to point lightning generation anywhere. Are there many other forms of generating 'lightning'? I was told this is what I want. What algorithms exist for forked lightning, or 2D trees ...

Simple Generics -- Is this possible Method<typeof(T)>()?

I am attempting to create a generic mapping function that takes the values of a dictionary and its sub classes and maps them to the fields in T using reflection. Within object T, there are sub objects that must be drilled into, and through recursion, it seems like a pretty simple concept. However I am stuck -- and I'm not sure if it's ...

parsing xml with applescript or maybe shell

I need t parse xml for an applescript project and i got a start but for some reason my code is not operating the way I expected it to it does find the item I'm looking for but does not return a value here is the code set xmlFile to ((choose file without invisibles) as string) tell application "System Events" set xdata to XML elem...

Linq extension method, how to find child in collection recursive

Hi, I'm already familiar with Linq but have little understanding of extension methods I'm hoping someone can help me out. So I have this hierarchical collection pseudo code ie: class Product prop name prop type prop id prop List<Product> children And I have a list of products List products. Is there any way I can look for pr...

Is a concurrency approach a good idea for speeding a long iteration?

I have an app that does an iteration to create points on a graph over time. While I'm gathering data for each point across the x-axis I also must execute a recursive lookup which effectually means I have a loop inside another loop. This is not scaling too well. I don't see a lot of examples of using a "divide and conquer" solution on it...

How to prevent unnecessary memory use in recursive functions

I've just written a recursive function and it dawned on me that all the variables I use within the function will remain allocated in memory until recursion breaks. If I am recursing a large number of times or allocating large amounts of memory for variables not used in the consequent recursive function call, could this lead to alot of w...

Stuck with recursion within a loop

I am using recursion inside a loop. I want to stop the loop as soon as the method is called recursively and resume it again when the call returns. I am not able to do so. Do I need to lock the method? Here is my code: import java.lang.Thread; public class Max2Friends extends Thread { String[] f = {"NYNNN", "YNYNN", "NYNYN", "NNYNY...

Recursive regex

Hi there ! I have the following string in php: $string = 'FEDCBA9876543210'; The string can be have 2 or more (I mean more) hexadecimal characters I wanted to group string by 2 like : $output_string = 'FE:DC:BA:98:76:54:32:10'; I wanted to use regex for that, I think I saw a way to do like "recursive regex" but I can't remember i...

Why won't recursive generator work?

Hi all, I have a class where each instance is basically of a bunch of nested lists, each of which holds a number of integers or another list containing integers, or a list of lists, etc., like so: class Foo(list): def __init__(self): self.extend( list(1), list(2), list(3), range(5), [range(3), range(2)] ...

Generate "explorer tree" in Java efficiently (not using recursion)

Hi All, I have a question which could be language-agnostic but for this particular implementation I'm using Java. It is possible and relatively trivial to list the folders in a directory - using a function like this: private DefaultMutableTreeNode GenerateFSTree(File f) { int i = 0; File[] Children = f.listFiles(); Default...

Most Efficient way to Recursively Flatten Nested Array to Dot-separated string in Ruby?

I want to convert something like this: class NestedItem attr_accessor :key, :children def initialize(key, &block) self.key = key self.children = [] self.instance_eval(&block) if block_given? end def keys [key] + children.keys end end root = NestedItem.new("root") do children << NestedItem.new("parent_a") do...