Hi im trying to figure out how to recursively search a tree to find a character and the binary code to get to that character. basically the goal is to go find the code for the character and then write it to a file. the file writer part i can do no problem but the real problem is putting the binary code into a string. while im searching f...
Hi I have a json string converted unsing the JSON framework into a dictionary and I need to extract its content. How could I iterate to the nested dictionaries? I have already this code that allows me to see the dictionary:
NSDictionary *results = [responseString JSONValue];
NSMutableArray *catArray = [NSMutableArray array];
for (id k...
(define pick
(lambda (num lat)
(cond ((null? lat) (quote()))
((= (sub1 num) 0) (car lat))
(else
(pick (sub1 num) (cdr lat))))))
(define brees (quote (a b c d e touchdown g h i)))
(pick 6 brees)
The language in DrRacket is set to Advanced Student. It also works fine in the IronScheme...
I have this tail recursive function here:
def fib(n, sum):
if n < 1:
return sum
else:
return fib(n-1, sum+n)
c = 998
print(fib(c, 0))
It works up to n=997, then it just breaks and spits a "maximum recursion depth exceeded in comparison" RuntimeError. Is this just a stack overflow? Is there a way to get around ...
I am trying to develop a Recursive Extractor. The problem is , it is Recursing Too Much (Evertime it found an archive type) and taking a performance hit.
So how can i improve below code?
My Idea 1:
Get the 'Dict' of direcories first , together with file types.Filetypes as Keys. Extract the file types. When an Archive is found Extract ...
Hello guys,
I would like to write a recursive PHP function to retrive all the children for the specified category. I tried the one described here but it didn't output what I have expected.
My categories table looks like this:
CREATE TABLE `categories` (
`category_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`category_name` var...
I have two tables that look a little like this
AGR_TERR_DEF_TERRS
ID
DEF_ID
TERRITORY_ID (foreign key links to TERRITORIES.ID)
TERRITORIES
ID
NAME
PARENT_ID
(parent_id and id are recursive)
Given two DEF_IDs, I need a function which checks whether the territories of one is a complete subset of the other.
I've been playing...
Hi.
I have a problem at hand, which can be stated as follows.
There are two set of nodes (in a bipartite directed graph), type1 and type2.
For every node in the graph of type1, I have to find out a set which is constructed in this fashion:
Let node1 be the first node of type1.
Add node1 in the set.
For node1, find out the list of nod...
Below are the functions that I use to download a FTP folder, recursively.
I ran this several times, but after a successful run for like 1-2 mins, it always stops on the same spot, at the same file, generating this :
......
......
Downloaded: login-bkg-bottom.gif
Downloaded: login-bkg-tile.gif
Downloaded: logo-ghost.png
Downloaded: logo-...
I have the following method that works well, except the yield break statement only breaks out of the current enumerator. I understand why this is the case, but I am drawing a blank over how to propogate the yield break up through the recursive stack.
private static IEnumerable<Node> FindChildrenById(IEnumerable nodes, string parentT...
I have written a recursive Tree Function in pascal ( or delphi ) but i had an 'Out of Memory' message when I ran it.
I need to turn the Calculate recursive function in this code to non-recursive function, can you tell me how please :
program testing(input,output);
type
ptr = ^tr;
tr = record
age:byte;
left,right:ptr;
end...
I'm still plugging away at the exercises in How to Design Programs on my own, but have managed to get stuck again. This time it's question 11.4.7:
Develop the function
is-not-divisible-by<=i. It consumes a
natural number [>=1], i, and a natural
number m, with i < m. If m is not
divisible by any number between 1
(exclusive) ...
Hi, I'm trying to create a class which must be superclass of others, tracing their attribute requests. I thought of using "getattribute" which gets all attribute requests, but it generates recursion:
class Mixin(object):
def __getattribute__ (self, attr):
print self, "getting", attr
return self.__dict__[attr]
I know why I ...
Hello,
I hope you guys can help me with this one. So, I have a products table and a categories table. The structure for the categories table is listed bellow. There will be about 20 categories with three or four levels deep. In order to get the category tree a wrote a recursive function and it is working fine.
My new task is to displa...
I'm using a modal plugin (colorbox) that has an option "onComplete". I can do the following to achieve part of the effect I'm going for (this is just the "onComplete" option):
onComplete: function(){
$('.ajaxform').ajaxForm({
success: function(responseText){
$.colorbox({html:responseText});
}
...
Dear All,
Can a python class contain an instance of itself as a data container may look like this?
class A:
def __init__(self, val):
self.a = A(val)
self.val = val
aa = A(2)
#this will cause RuntimeError: maximum recursion depth exceeded
my purpose is using this class as a data container contain a copy inside if...
Edit: I discovered a partial answer to my own question in the process of writing this, but I think it can easily be improved upon so I will post it anyway. Maybe there's a better solution out there?
I am looking for an easy way to define recursive functions in a let form without resorting to letfn. This is probably an unreasonable reque...
Hello,
I can't seem to be able to convince scp to behave.
For test data
ubuntu@domU-12-31-38-00-D4-F1:/tmp$ find /tmp/a1/
/tmp/a1/
/tmp/a1/a2
/tmp/a1/a2/a3
On issuing the command
ubuntu@domU-12-31-38-00-D4-F1:/tmp$ scp -r /tmp/a1 domU-12-31-38-00-E2-52.compute-1.internal:/tmp/a1
I would expect the same directory structure created...
Hi, I am trying to parse a JSON output:
http://www.freebase.com/experimental/topic/standard?id=/en/colonel_sanders
I'd like to put the basic data into an array using Javascript. In the "properties" object I'd like to grab any "text" element one level under "properties" as a label and grab the "text" under the "values" object to match t...
I'm getting used to Haskell's higher-order functions. Usually I can replace explicit patterns of recursion with functions like map, fold, and scan. However, I often run into the following recursion pattern which I don't understand how to express using higher-order functions:
f (x:[]) = k x
f (x:xs) = g x (f xs)
For instance, sup...