Search Results

Search found 1112 results on 45 pages for 'recursive'.

Page 3/45 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Problem with recursive rar archiving non-ascii filenames

    - by AndreasT
    Say I want to create a backup of folder MainFolder's content using rar. The command rar a Backup.rar -r MainFolder does the job. BUT, if a subdirectory contains more than one file named with non-ASCII (?) characters, then only one of them is archived and the others get excluded. For example, consider the following directory hierarchy (MainFolder, A and B are folders; a, b, ? and ? are files) +MainFolder +A -a -b -? -? +B -a -b -a -b -? -? then the command rar a Backup.rar -r MainFolder skips MainFolder/A/? MainFolder/? while rar a Backup.rar -r MainFolder/* still skips MainFolder/A/? Why is it so? Any help is greatly appreciated, thanks! For the record, I already encountered some issues with non-ascii characters (see this question) that other Linux distributions seem not to have. Anyway, I use Lubuntu 12.04, terminal is lxterminal and echo $BASH_VERSION returns 4.2.25(1)-release. rar version is 4.00 beta 3. Another curiosity: right-clicking on the folder and selecting Compress... and then .rar still has the same problem. Other options (zip, tar...) behave correctly.

    Read the article

  • Defining a function that is both a generator and recursive [on hold]

    - by user96454
    I am new to python, so this code might not necessarily be clean, it's just for learning purposes. I had the idea of writing this function that would display the tree down the specified path. Then, i added the global variable number_of_py to count how many python files were in that tree. That worked as well. Finally, i decided to turn the whole thing into a generator, but the recursion breaks. My understanding of generators is that once next() is called python just executes the body of the function and "yields" a value until we hit the end of the body. Can someone explain why this doesn't work? Thanks. import os from sys import argv script, path = argv number_of_py = 0 lines_of_code = 0 def list_files(directory, key=''): global number_of_py files = os.listdir(directory) for f in files: real_path = os.path.join(directory, f) if os.path.isdir(real_path): list_files(real_path, key=key+' ') else: if real_path.split('.')[-1] == 'py': number_of_py += 1 with open(real_path) as g: yield len(g.read()) print key+real_path for i in list_files(argv[1]): lines_of_code += i print 'total number of lines of code: %d' % lines_of_code print 'total number of py files: %d' % number_of_py

    Read the article

  • Recursive function with for loop python

    - by user134743
    I have a question that should not be too hard but it has been bugging me for a long time. I am trying to write a function that searches in a directory that has different folders for all files that have the extension jpg and which size is bigger than 0. It then should print the sum of the size of the files that are in these categories. What I am doing right now is def myFuntion(myPath, fileSize): for myfile in glob.glob(myPath): if os.path.isdir(myFile): myFunction(myFile, fileSize) if (fnmatch.fnmatch(myFile, '*.jpg')): if (os.path.getsize(myFile) > 1): fileSize = fileSize + os.path.getsize(myFile) print "totalSize: " + str(fileSize) THis is not giving me the right result. It sums the sizes of the files of one directory but it does not keep suming the rest. For example if I have these paths C:/trial/trial1/trial11/pic.jpg C:/trial/trial1/trial11/pic1.jpg C:/trial/trial1/trial11/pic2.jpg and C:/trial/trial2/trial11/pic.jpg C:/trial/trial2/trial11/pic1.jpg C:/trial/trial2/trial11/pic2.jpg I will get the sum of the first three and the the size of the last 3 but I won´t get the size of the 6 together, if that makes sense. Thank you so much for your help!

    Read the article

  • Recursive algorithm for coalescing / collapsing list of dates into ranges.

    - by Dycey
    Given a list of dates 12/07/2010 13/07/2010 14/07/2010 15/07/2010 12/08/2010 13/08/2010 14/08/2010 15/08/2010 19/08/2010 20/08/2010 21/08/2010 I'm looking for pointers towards a recursive pseudocode algorithm (which I can translate into a FileMaker custom function) for producing a list of ranges, i.e. 12/07/2010 to 15/07/2010, 12/08/2010 to 15/08/2010, 19/08/2010 to 20/08/2010 The list is presorted and de-deuplicated. I've tried starting from both the first value and working forwards, and the last value and working backwards but I just can't seem to get it to work. Having one of those frustrating days... It would be nice if the signature was something like CollapseDateList( dateList, separator, ellipsis ) :-)

    Read the article

  • Prevent recursive CTE visiting nodes multiple times

    - by bacar
    Consider the following simple DAG: 1->2->3->4 And a table, #bar, describing this (I'm using SQL Server 2005): parent_id child_id 1 2 2 3 3 4 //... other edges, not connected to the subgraph above Now imagine that I have some other arbitrary criteria that select the first and last edges, i.e. 1-2 and 3-4. I want to use these to find the rest of my graph. I can write a recursive CTE as follows (I'm using terminology from MSDN): with foo(parent_id,child_id) as ( // anchor member that happens to select first and last edges: select parent_id,child_id from #bar where parent_id in (1,3) union all // recursive member: select #bar.* from #bar join foo on #bar.parent_id = foo.child_id ) select parent_id,child_id from foo However, this results in edge 3-4 being selected twice: parent_id child_id 1 2 3 4 2 3 3 4 // 2nd appearance! How can I prevent the query from recursing into subgraphs that have already been described? I could achieve this if, in my "recursive member" part of the query, I could reference all data that has been retrieved by the recursive CTE so far (and supply a predicate indicating in the recursive member excluding nodes already visited). However, I think I can access data that was returned by the last iteration of the recursive member only. This will not scale well when there is a lot of such repetition. Is there a way of preventing this unnecessary additional recursion? Note that I could use "select distinct" in the last line of my statement to achieve the desired results, but this seems to be applied after all the (repeated) recursion is done, so I don't think this is an ideal solution. Edit - hainstech suggests stopping recursion by adding a predicate to exclude recursing down paths that were explicitly in the starting set, i.e. recurse only where foo.child_id not in (1,3). That works for the case above only because it simple - all the repeated sections begin within the anchor set of nodes. It doesn't solve the general case where they may not be. e.g., consider adding edges 1-4 and 4-5 to the above set. Edge 4-5 will be captured twice, even with the suggested predicate. :(

    Read the article

  • Drawing the call stack in a recursive method

    - by Shaza
    Hey, I want to draw the call stack for any recursive method, so I've created a schema like this, recursiveMethod(){ //Break recursion condition if(){ // Add value here to the return values' list- No drawing return } else{ //Draw stack with the value which will be pushed to the stack here variable <- recursiveMethod() //Clear the drawing which represents the poped value from the stack here return variable }} Notes: This schema can draw recursive methods with n recursive call by making the recursive calls in a separate return statements. returnValues list, is a list which save all the return values, just for viewing issues. What do you think of this? any suggestions are extremely welcomed.

    Read the article

  • Recursive vs. Iterative algorithms

    - by teehoo
    I'm implementing the Euclidian algorithm for finding the GCD (Greatest Common Divisor) of two integers. Two sample implementations are given: Recursive and Iterative. http://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations My Question: In school I remember my professors talking about recursive functions like they were all the rage, but I have one doubt. Compared to an iterative version don't recursive algorithms take up more stack space and therefore much more memory? Also, because calling a function requires uses some overhead for initialization, aren't recursive algorithms more slower than their iterative counterpart?

    Read the article

  • slowing down a loop in a recursive function

    - by eco_bach
    I have a difficult problem with a recursive function. Essentially I need to 'slow down' a for loop within a function that repeatedly calls itself(the function); Is this possible, or do I need to somehow extract the recursive nature of the function? function callRecursiveFuncAgain(ob:Object):void{ //do recursive stuff; for (var i:int = 0; i < 4; i++) { _nextObj=foo callRecursiveFuncAgain(_nextObj); } }

    Read the article

  • Apply a recursive CTE on grouped table rows (SQL server 2005).

    - by Evan V.
    Hi all, I have a table (ROOMUSAGE) containing the times people check in and out of rooms grouped by PERSONKEY and ROOMKEY. It looks like this: PERSONKEY | ROOMKEY | CHECKIN | CHECKOUT | ROW ---------------------------------------------------------------- 1 | 8 | 13-4-2010 10:00 | 13-4-2010 11:00 | 1 1 | 8 | 13-4-2010 08:00 | 13-4-2010 09:00 | 2 1 | 1 | 13-4-2010 15:00 | 13-4-2010 16:00 | 1 1 | 1 | 13-4-2010 14:00 | 13-4-2010 15:00 | 2 1 | 1 | 13-4-2010 13:00 | 13-4-2010 14:00 | 3 13 | 2 | 13-4-2010 15:00 | 13-4-2010 16:00 | 1 13 | 2 | 13-4-2010 15:00 | 13-4-2010 16:00 | 2 I want to select just the consecutive rows for each PERSONKEY, ROOMKEY grouping. So the desired resulting table is: PERSONKEY | ROOMKEY | CHECKIN | CHECKOUT | ROW ---------------------------------------------------------------- 1 | 8 | 13-4-2010 10:00 | 13-4-2010 11:00 | 1 1 | 1 | 13-4-2010 15:00 | 13-4-2010 16:00 | 1 1 | 1 | 13-4-2010 14:00 | 13-4-2010 15:00 | 2 1 | 1 | 13-4-2010 13:00 | 13-4-2010 14:00 | 3 13 | 2 | 13-4-2010 15:00 | 13-4-2010 16:00 | 1 I want to avoid using cursors so I thought I would use a recursive CTE. Here is what I came up with: ;with CTE (PERSONKEY, ROOMKEY, CHECKIN, CHECKOUT, ROW) as (select RU.PERSONKEY, RU.ROOMKEY, RU.CHECKIN, RU.CHECKOUT, RU.ROW from ROOMUSAGE RU where RU.ROW = 1 union all select RU.PERSONKEY, RU.ROOMKEY, RU.CHECKIN, RU.CHECKOUT, RU.ROW from ROOMUSAGE RU inner join CTE on RU.ROWNUM = CTE.ROWNUM + 1 where CTE.CHECKIN = RU.CHECKOUT and CTE.PERSONKEY = RU.PERSONKEY and CTE.ROOMKEY = RU.ROOMKEY) This worked OK for very small datasets (under 100 records) but it's unusable on large datasets. I'm thinking that I should somehow apply the cte recursevely on each PERSONKEY, ROOMKEY grouping on my ROOMUSAGE table but I am not sure how to do that. Any help would be much appreciated, Cheers!

    Read the article

  • How to prevent recursive windows when connecting to vncserver on localhost

    - by blog.adaptivesoftware.biz
    I have a VNCServer (vino) configured on my Ubuntu 8.10 box. I would like to connect to this server from a vncclient running on this same machine (the reason for doing this strange thing is mentioned below). Understandably, when I connect to a vncserver on the same box, my vncclient shows recursive windows. Is there a way I can connect to the vncserver on the same machine and not have the recursive windows problem? Perhaps if I could start the vncserver on one display and the client on another display then will it work? How can I do something like this? Note - Reason for running vnc client and server on the same machine: When I start our Java Swing unit test suite, a bunch of swing UI's are created and destroyed as the tests run. These windows fly in the foreground making it impossible to work while the test suite is running. I am hoping to start the test suite within a vncclient so that I can continue working while the tests run.

    Read the article

  • Public Facing Recursive DNS Servers - iptables rules

    - by David Schwartz
    We run public-facing recursive DNS servers on Linux machines. We've been used for DNS amplification attacks. Are there any recommended iptables rules that would help mitigate these attacks? The obvious solution is just to limit outbound DNS packets to a certain traffic level. But I was hoping to find something a little bit more clever so that an attack just blocks off traffic to the victim IP address. I've searched for advice and suggestions, but they all seem to be "don't run public-facing recursive name servers". Unfortunately, we are backed into a situation where things that are not easy to change will break if we don't do so, and this is due to decisions made more than a decade ago before these attacks were an issue.

    Read the article

  • Can a destructor be recursive?

    - by Cubbi
    Is this program well-defined, and if not, why exactly? #include <iostream> #include <new> struct X { int cnt; X (int i) : cnt(i) {} ~X() { std::cout << "destructor called, cnt=" << cnt << std::endl; if ( cnt-- > 0 ) this->X::~X(); // explicit recursive call to dtor } }; int main() { char* buf = new char[sizeof(X)]; X* p = new(buf) X(7); p->X::~X(); // explicit call to dtor delete[] buf; } My reasoning: although invoking a destructor twice is undefined behavior, per 12.4/14, what it says exactly is this: the behavior is undefined if the destructor is invoked for an object whose lifetime has ended Which does not seem to prohibit recursive calls. While the destructor for an object is executing, the object's lifetime has not yet ended, thus it's not UB to invoke the destructor again. On the other hand, 12.4/6 says: After executing the body [...] a destructor for class X calls the destructors for X's direct members, the destructors for X's direct base classes [...] which means that after the return from a recursive invocation of a destructor, all member and base class destructors will have been called, and calling them again when returning to the previous level of recursion would be UB. Therefore, a class with no base and only POD members can have a recursive destructor without UB. Am I right?

    Read the article

  • Java iterative vs recursive

    - by user1389813
    Can anyone explain why the following recursive method is faster than the iterative one (Both are doing it string concatenation) ? Isn't the iterative approach suppose to beat up the recursive one ? plus each recursive call adds a new layer on top of the stack which can be very space inefficient. private static void string_concat(StringBuilder sb, int count){ if(count >= 9999) return; string_concat(sb.append(count), count+1); } public static void main(String [] arg){ long s = System.currentTimeMillis(); StringBuilder sb = new StringBuilder(); for(int i = 0; i < 9999; i++){ sb.append(i); } System.out.println(System.currentTimeMillis()-s); s = System.currentTimeMillis(); string_concat(new StringBuilder(),0); System.out.println(System.currentTimeMillis()-s); } I ran the program multiple time, and the recursive one always ends up 3-4 times faster than the iterative one. What could be the main reason there that is causing the iterative one slower ?

    Read the article

  • What does this code do? Recursive Iterator in php?

    - by Ali
    I'm working on a zend framework based email project and I'm following some code samples online.. I can't understand this line of code which apparently loops through different 'parts' of an email message. I have no idea how it works btw and suspect that theres some error taking place which my parser isn't showing right. foreach (new RecursiveIteratorIterator($mail->getMessage($i)) as $ii=>$part) what does the above foreach loop mean?

    Read the article

  • Recursive Syntax in Oslo

    - by Kevin Lawrence
    I'm writing my first DSL with Oslo and I am having a problem with a recursive syntax definition. The input has sections which can contain questions or other sections recursively (composite pattern) like this: Section: A Question: 1 Question: 2 Section: B Question: 1 End End My definition for a Section looks like this syntax Section = "Section:" id:Text body:(SectionBody)* "End Section"; Which works (but doesn't handle recursive sections) if I define SectionBody like this syntax SectionBody = (Question); but doesn't work with a recursive definition like this syntax SectionBody = (Question | Section); What am I missing?

    Read the article

  • wget recursive limited within subdomain

    - by Paul Seangwongree
    I want to download the following subdomain with the recursive option using wget: www.example.com/A/B So if that URL has links to www.example.com/A/B/C and www.example.com/A/B/D, these two should also be downloaded. But I don't want anything outside the www.example.com/A/B subdomain to be downloaded. For example, if www.example.com/A/B/C has a link back to www.example.com, the page www.example.com should not be downloaded. What wget command should I use?

    Read the article

  • Correct way to model recursive relationship in Django

    - by Yuval A
    My application has two node types: a parent node which can hold recursive child nodes. Think of it like the post-comment system in SO, but comments can be recursive: parent_1 child_11 child_12 child_121 child_3 parent_2 child_21 child_211 child_2111 Important to note that the parent nodes have different attributes and behavior than the child nodes. What is the correct (and presumably most efficient) way of modeling this relationship in Django?

    Read the article

  • Recognizing Tail-recursive functions with Flex+Bison and convert code to an Iterative form

    - by Viet
    I'm writing a calculator with an ability to accept new function definitions. Being aware of the need of newbies to try recursive functions such as Fibonacci, I would like my calculator to be able to recognize Tail-recursive functions with Flex + Bison and convert code to an Iterative form. I'm using Flex & Bison to do the job. If you have any hints or ideas, I welcome them warmly. Thanks!

    Read the article

  • Recursive insert-method for a linked list

    - by user3726477
    I'm learning C# and I've made a recursive insert-method for a linked list: public static int recursiveInsert(ref int value, ref MyLinkedList list) { if (list == null) return new MyLinkedList(value, null); else { list.next = recursiveInsert(ref int value, ref list.next); return list; } } How would you modify this method to make the recursive call look like this: recursiveInsert(value, ref list.next) instead of: list.next = recursiveInsert(ref int value, ref list.next);

    Read the article

  • Scala: recursive search avoiding cycles

    - by user1826663
    How can I write a recursive search that I avoid cycles. My class is this: class Component(var name: String, var number: Int, var subComponent: Set[Component]) Now I need a way to check whether a component is contained within its subcomponent or between subcomponent of its subcomponent and so on.Avoiding possible cycles caused by other Component. My method of recursive search must have the following signature, where subC is the Set [component] of comp. def content (comp: Component, subC: Set[Component]) : Boolean = { } Thanks for the help.

    Read the article

  • Simple recursive DNS resolver for debugging (app or VM)

    - by notpeter
    I have an issue which I believe is caused by incorrect DNS queries (doubled subdomains like _record.host.subdomain.tld.subdomain.tld) when querying for SRV records. So I need to an alternate DNS server with heavy logging so I can see every query (especially stupid ones), acting as a recursive resolver with the ability create records which override real DNS records so I can not only find the records it's (wrongly) looking for, but populate those records as well. I know I could install a DNS server on yet another linux box, but I feel like this is the sort of thing that someone may already setup a simple python script or single use vm just for this purpose.

    Read the article

  • Tail-recursive merge sort in OCaml

    - by CFP
    Hello world! I’m trying to implement a tail-recursive list-sorting function in OCaml, and I’ve come up with the following code: let tailrec_merge_sort l = let split l = let rec _split source left right = match source with | [] -> (left, right) | head :: tail -> _split tail right (head :: left) in _split l [] [] in let merge l1 l2 = let rec _merge l1 l2 result = match l1, l2 with | [], [] -> result | [], h :: t | h :: t, [] -> _merge [] t (h :: result) | h1 :: t1, h2 :: t2 -> if h1 < h2 then _merge t1 l2 (h1 :: result) else _merge l1 t2 (h2 :: result) in List.rev (_merge l1 l2 []) in let rec sort = function | [] -> [] | [a] -> [a] | list -> let left, right = split list in merge (sort left) (sort right) in sort l ;; Yet it seems that it is not actually tail-recursive, since I encounter a "Stack overflow during evaluation (looping recursion?)" error. Could you please help me spot the non tail-recursive call in this code? I've searched quite a lot, without finding it. Cout it be the let binding in the sort function? Thanks a lot, CFP.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >