recursion

ANTLR4 mutual left recursion grammar

醉酒当歌 提交于 2020-01-10 05:45:06
问题 I have read many questions here on StackOverflow about mutual left-recursion issues in LL(k) parsers. I found the general algorithm for removing left-recursion: A : Aa | b ; becomes A : bR ; R : (aA)? ; However, I cannot figure out how to apply it to my situation. I have left_exp: IDENT | exp DOT IDENT ; exp : handful | of | other rules | left_exp ; The "handful of other rules" all contain regular recursion, such as exp : exp PLUS exp , etc. and have no issues. The issue is with left_exp and

Javascript recursive function not returning value?

青春壹個敷衍的年華 提交于 2020-01-10 05:38:07
问题 Im solving a codewars problem and im pretty sure i've got it working: function digital_root(n) { // ... n = n.toString(); if (n.length === 1) { return parseInt(n); } else { let count = 0; for (let i = 0; i < n.length; i++) { //console.log(parseInt(n[i])) count += parseInt(n[i]); } //console.log(count); digital_root(count); } } console.log(digital_root(942)); Essentially it's supposed to find a "digital root": A digital root is the recursive sum of all the digits in a number. Given n, take the

How can I configure call depth in PowerShell?

橙三吉。 提交于 2020-01-10 05:11:12
问题 I was just trying things in PowerShell and got an error about call depth being set to 1000 in some test recursive function. I looked on the Internet for some information and found that this is due to error handling in PowerShell (if I got it right): The recursion depth limit is fixed in version 1. Deep recursion was causing problems in 64-bit mode because of the way exceptions were being processed. It was causing cascading out-of-memory errors. The net result was that we hard-limited the

Ordering hierarchy from recursive query results in SQL 2005

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-09 23:49:11
问题 I've got a 'Task' table with the following columns (the TaskOrder is for ordering the children within the scope of the parent, not the entire table): TaskId ParentTaskId TaskName TaskOrder I've got this CTE query to return all the rows: with tasks (TaskId, ParentTaskId, [Name]) as ( select parentTasks.TaskId, parentTasks.ParentTaskId, parentTasks.[Name] from Task parentTasks where ParentTaskId is null union all select childTasks.TaskId, childTasks.ParentTaskId, childTasks.[Name] from Task

BASH: recursive program to replace text in a tree of files

ぐ巨炮叔叔 提交于 2020-01-09 19:06:31
问题 I am completely new at Bash but I just can't seem to find a way to make it do what I want. Imagine you have a tree directory with 2 files: /top.php and /test/bottom.php How do I make my function look and replace say "hello" into "bonjour" in /top.php AND in /test/bottom.php? So far the only way I have found to do this is by calling the same function twice with a different depth level: find ./*.php -type f -exec sed -i 's/hello/bonjour/' {} \; find ./*/*.php -type f -exec sed -i 's/hello

BASH: recursive program to replace text in a tree of files

一世执手 提交于 2020-01-09 19:03:50
问题 I am completely new at Bash but I just can't seem to find a way to make it do what I want. Imagine you have a tree directory with 2 files: /top.php and /test/bottom.php How do I make my function look and replace say "hello" into "bonjour" in /top.php AND in /test/bottom.php? So far the only way I have found to do this is by calling the same function twice with a different depth level: find ./*.php -type f -exec sed -i 's/hello/bonjour/' {} \; find ./*/*.php -type f -exec sed -i 's/hello

Trim white spaces in both Object key and value recursively

安稳与你 提交于 2020-01-09 13:14:00
问题 How do you trim white spaces in both the keys and values in a JavaScript Object recursively? I came across one issue in which I was trying to "clean" a user supplied JSON string and send it into my other code for further processing. Let's say we've got a user supplied JSON string whose property key and value are of type "string". However, what's problematic in this case is that the keys and values are not as clean as desired. Say a { " key_with_leading_n_trailing_spaces ": " my_value_with

Trim white spaces in both Object key and value recursively

China☆狼群 提交于 2020-01-09 13:08:02
问题 How do you trim white spaces in both the keys and values in a JavaScript Object recursively? I came across one issue in which I was trying to "clean" a user supplied JSON string and send it into my other code for further processing. Let's say we've got a user supplied JSON string whose property key and value are of type "string". However, what's problematic in this case is that the keys and values are not as clean as desired. Say a { " key_with_leading_n_trailing_spaces ": " my_value_with

Detect Recursive calls in C# code

為{幸葍}努か 提交于 2020-01-09 12:51:32
问题 I want to find all recursive calls in my code. If I open file in Visual Studio, I get "Recursive call" icon on left side of Editor. I want to inspect whole solution for such calls. I used Resharper Command Line tools and VS's add-in Resharper - Code Inspection with no luck, this rule is not applied in their ruleset. Is there any way that i could inspect whole solution - i really don't want to open each file and check for that blue-ish "Recursive call" icon :) Edit: I am interested in single

Recursive method to search through folder tree and find specific file types

倖福魔咒の 提交于 2020-01-09 11:46:58
问题 So I am writing a code that locates certain information on Protein databases. I know that a recursive folder search is the best possible way to locate these files, but I am very new to this language and have been told to write in Java (I normally do C++) SO this being said, what method would i use to: First: Locate the folder on desktop Second: Open each folder and that folders subfolders Third: Locate files that end with the ".dat" type (because these are the only files that have stored the