I have a situation where I want to have a stored proc returning a table that calls itself recursively as part of its calculation.
Unfortunately SQL Server is having none of this and gives me an error along the lines of both being unable to declare a cursor that already exists and about not being able to nest and insert exec statement....
Hello all
I have two complex dictionaries in the form
Dictionary<string, Dictionary<string, Dictionary<string, List<string>>>>
So as you see i've inner dictionaries. I want to write a generic recursive function which can merge two complex dictionaries of this form (or any other complex form of dictionaries), by calling itself passing...
Is there a way to make the something like the following code work?
add = lambda n: (yield n) or add(n+1)
(answers don't need to be in functional style)
...
I can't seem to really think of a way to solve this one, can't get my brain around it for some reason. The problem I'm trying to solve is this:
For a puzzle-solver type algorithm, I'm pulling the duplicate letters as a substring of an NSString. Let's say the user enters "RBEEEIOOUUU"
I'm pulling just the duplicates from their string, ...
Hi,
I use CakePHP 1.2.6 and have the following relations:
Showcase HABTM User belongsTo Galleryitem hasOne Image
I try to get all the data related to a Showcase, and therefor also all its users with their Galleryitem -> Image. I use the following query:
$showcase = $this->Showcase->find('first',
array('conditions'=>array('Showcase...
I just wrote this function to break a number into its prime factors. Is the algorithm I'm using a good one? How might I improve this function? So far it seems to be working quite well.
from copy import copy
# Decorator to memoize using the first argument only
@memoize_first
def prime_factors(n, prime_list=[None], prime_limit=[None]):
...
I have a need to run a recursive CTE within a stored proc, but I can't get it past this:
SQL0104N An unexpected token "with" was found following "SET count=count+1;
". Expected tokens may include: "". LINE NUMBER=26.
My google-fu showed a couple of similar topics, but none with resolution.
The query functions as expected outside of the...
What's the maximum level of recursion and how do I change it in Python?
...
If I recall correctly, tail recursive functions always have an easy non-recursive equivalent.
Since recursion involves unnecessary function call overhead, it's better to do it the non-recursive way.
Is this assumption always true? Are there any other arguments for/against tail-recursion?
...
Hi,
I have so category and this categories have unlimited sub category.
In Database Table, Fields are ID, UpperID and Title.
If I call a category and its subcategory in DataTable with recursive method in program(ASP.NET project)
performance is very bad.
And many user will use this application so everything goes bad.
Maybe All categorie...
My data (spreadsheet):
'1',,,
,'1.1',,
,,'1.1.1',
,,'1.1.2',
,,'1.1.3',
,'1.2',,
,'1.3',,
,,'1.3.1',
,,'1.3.2',
,,'1.3.3',
'2',,,
,'2.1',,
,,'2.1.1',
,,,'2.1.1.1'
,,,'2.1.1.2'
,,,'2.1.1.3'
My model:
class Vocabulary(models.Model):
name = CharField(max_length=60)
class Concept(models.Model):
parent = ForeignKey('self', blank=...
Is it possible to write JSON parser without using recursion ? If it is, what approach would you suggest ?
...
I have the following function in my c# silverlight application to find the total sub nodes of a node in the tree
//get total children
private int getTotalChildren(int id)
{
int total=0;
for (int i = 0; i < persons.Count;i++ )
{
if (persons[i].Manager == id)
{
...
I am trying to loop through all files and folders and perform an action on all files that have a certain extension. This method works fine, but I would like to make it multithreaded because when done over tens of thousands of files, it is really slow and I would imaging using multithreading would speed things up. I am just unsure about h...
I have a function, in which there is a loop which calls up the function.
function displayItem(item, isChild)
{
if (isChild)
{
writeOutput('<li>' & item.name & '</li>');
}
else
{
writeOutput('<li>' & item.name);
}
try
{
if (item.hasChild)
{
writeOutput('<ul>');
...
Lets assume I have a loop for Foo.
int Foo(int n)
{
if (n <= 1)
return 2;
else
return Foo(n-1) * Foo(n-2) * Foo (n-3);
}
How many call will occur If i Call Foo(3) and what would be the result...
Thanks
...
Wondering if anyone could point me towards a good recursion tutorial. I am a bit rusty on it as I learned about it in my Data Structures class first semester. Would like to brush up on my recursion...any help?
...
I've looked at the related questions here but am having a slightly different problem.
I am rewriting anchors across nested iframes, sometimes 3 or 4 iframes deep.
I use .load( function(){} ) to wait for each to load before accessing the anchors. This works fine when only going one iframe deep, but fails after that.
Here is the code:
...
Hi,
I need help with a recursive query. Assuming the following table:
CREATE TEMPORARY TABLE tree (
id integer PRIMARY KEY,
parent_id integer NOT NULL,
name varchar(50)
);
INSERT INTO tree (id, parent_id, name) VALUES (3, 0, 'Peter'), (2,0, 'Thomas'), (5,2, 'David'), (1, 0, 'Rob'), (8, 0, 'Brian');
I can ...
I'm building an expression tree using discriminated unions. The below code:
type IntExpression =
| TrueIsOne of BoolExpression
type BoolExpression =
| LessThan of IntExpression * IntExpression
| And of BoolExpression * BoolExpression
| Or of BoolExpression * BoolExpression
| Bool of bool
throws an error because Bo...