pyinstaller creating EXE RuntimeError: maximum recursion depth exceeded while calling a Python object

This worked for me Run pyinstaller and stop it to generate the spec file : pyinstaller filename.py A file with .spec as extension should be generated Now add the following lines to the beginning of the spec file : import sys sys.setrecursionlimit(5000) Now run the spec file using : pyinstaller filename.spec

Longest word chain from a list of words

You can use recursion to explore every “branch” that emerges when every possible letter containing the proper initial character is added to a running list: words = [‘giraffe’, ‘elephant’, ‘ant’, ‘tiger’, ‘racoon’, ‘cat’, ‘hedgehog’, ‘mouse’] def get_results(_start, _current, _seen): if all(c in _seen for c in words if c[0] == _start[-1]): yield _current else: for … Read more

Recursively print all permutations of a string (Javascript)

Let’s write a function that returns all permutations of a string as an array. As you don’t want any global variables, returning the permutations is crucial. function permut(string) { if (string.length < 2) return string; // This is our break condition var permutations = []; // This array will hold our permutations for (var i … Read more

How do you write a fun that’s recursive in Erlang?

Since OTP 17.0 there are named funs: 1> Perms = fun F([]) -> [[]]; F(L) -> [[H|T] || H <- L, T <- F(L–[H])] end. #Fun<erl_eval.30.54118792> 2> Perms([a,b,c]). [[a,b,c],[a,c,b],[b,a,c],[b,c,a],[c,a,b],[c,b,a]] Before that you could do this with a little argument trick: 1> Foo = fun(F, X) -> F(F, X) end. #Fun<erl_eval.12.113037538> 2> Foo(Foo, a). <…infinite loop!> … Read more

Recursive List Flattening

Here’s an extension that might help. It will traverse all nodes in your hierarchy of objects and pick out the ones that match a criteria. It assumes that each object in your hierarchy has a collection property that holds its child objects. Here’s the extension: /// Traverses an object hierarchy and return a flattened list … Read more

Recursive listing of all files matching a certain filetype in Groovy

This should solve your problem: import static groovy.io.FileType.FILES new File(‘.’).eachFileRecurse(FILES) { if(it.name.endsWith(‘.groovy’)) { println it } } eachFileRecurse takes an enum FileType that specifies that you are only interested in files. The rest of the problem is easily solved by filtering on the name of the file. Might be worth mentioning that eachFileRecurse normally recurses … Read more

Regular expression to detect semi-colon terminated C++ for & while loops

You could write a little, very simple routine that does it, without using a regular expression: Set a position counter pos so that is points to just before the opening bracket after your for or while. Set an open brackets counter openBr to 0. Now keep incrementing pos, reading the characters at the respective positions, … Read more