I've been writing a little monadic parser-combinator library in F# (somewhat similar to FParsec) and now tried to implement a small parser for a programming language.
I first implemented the code in Haskell (with Parsec) which ran perfectly well.
The parsers for infix expressions are designed mutually recursive.
parseInfixOp :: Parser ...
Below is the code snippet with comments which describes the problem statement. We have an update trigger which internally calls another update trigger on the same table inspite of Recursive Trigger Enabled Property Set to false.
Would like to understand the reason for this as this is causing a havoc in my applications.
/* Drop statemen...
Possible Duplicates:
Is there a problem that has only a recursive solution?
Can every recursion be converted into iteration?
Necessary Uses of Recursion in Imperative Languages
Is there a problem that has only a recursive solution, that is, a problem that has a recursive solution, but an iterative solution has yet to be foun...
Hey everyone,
I am building an XML document successfully with the following code:
public function build($result) {
$root = $this->append(new xmlElement('data'));
$root->append(new xmlElement('collection'));
while($row = pg_fetch_assoc($result)){
foreach($row as $fieldname => $fieldvalue){
$second = $roo...
int fact_rec(int n)
{
printf("%d\n",n);
if(n==1) return n;
else return fact_rec(--n)*n;
//else return n*fact_rec(--n); gives same result
//correct output comes for n*fact(n-1)
}
In the above recursive implementation of the factorial function,
fact_rec(5) returns 24. Whereas, if I use
n*fact_rec(n-1)
in place of
n*fa...
I have a programming assignment in Perl that requires me to do the following:
Creates a table in a mySQL database, and inserts these records into it:
Loads the data from the table into an array of instances of class Son.
Using the array, creates HTML code representing a father-son tree, and prints the html code to STDOUT. It's not nece...
I have an object that represents a Location. Locations can contain other locations. How can I represent this relationship with Fluent NHibernate. The class looks like this:
public class Location : EntityBase
{
#region Properties
public string LocationName { get; set; }
public Location ParentLocation { get; private set; }
...
Hi guys. I am running the current version of ActivePerl on Windows Vista, and I was wondering if you could show me the best and simplest way to copy a folder and it's contents to another location. Contents would include various files, and most likely some more nested folders.
I imagine there must be a module out there somewhere that I ...
In .NET & C#, suppose ClassB has a field that is of type ClassA.
One can easily use method GetFields to list ClassB's fields.
However, I want to also list the fields of those ClassB fields that themselves have fields.
For example, ClassB's field x has fields b, s, and i. I'd like to (programmatically) list those fields (as suggested by ...
I've got a fairly simple method which recursively removes begining/ending html tags
class Program
{
static void Main(string[] args)
{
string s = FixHtml("<div><p>this is a <strong>test</strong></p></div>");
Console.WriteLine(s);
}
private static string FixHtml(string s)
...
Hi,
I'm trying to create a recursive function (or method) that stores a sub-tiered navigation in an array variable or object. Here is what I have:
class Navigation extends Database
{
function build($parent_id = 0)
{
$query = 'SELECT id, name, href, parent_id
FROM navigation
WHERE parent_id = '.$parent_id.'
...
guidance appreciated :)
(defn length
[xs]
(if ,(not= xs nil)
(println (+ 1 (length (rest xs))))
(println 0)))
...
I iterate through a tree structure to collect the paths of the leaf nodes. Which way do you prefer to collect the result of the operation:
a) merge the results of the children and return this
private Collection<String> extractPaths(final Element element, final IPath parentPath) {
final IPath path = parentPath.append(element.getLabe...
I have no idea about tower of hanoi. I want to write a program on this using recursion.
...
Tail recursive method to multiple 2 numbers
public static int Multiply2(int x, int y)
{
return MulTail(x, y, x);
}
public static int MulTail(int x, int y, int result)
{
if (y == 0 || x == 0)
return 0;
if (y == 1)
return result;
return MulTail(x, y - 1, result+x);
}
Changed the implementation to accom...
Can someone hep me find an algorithm for a recursive function func(int k) to return 3^k in only n+1 calls where k is in the range [ 3^n, 3^(n+1) )
For example, the function should return 3^1 or 3^2 in 1 call, 3^3, 3^4, .. 3^8 in 2 calls, 3^9, 3^10 .. in 3 calls and so on.
...
I have a situation in a WebForm where I need to recurse throguh the control tree to find all controls that implement a given interface.
How would I do this?
I have tried writing an extension method like this
public static class ControlExtensions
{
public static List<T> FindControlsByInterface<T>(this Control control)
{
...
Is there a way to perform the following in a non-recursive fashion:
my_list = [
"level 1-1",
"level 1-2",
"level 1-3",
[
"level 2-1",
"level 2-2",
"level 2-3",
[
"level 3-1",
"level 3-2"
]
],
"level 1-4",
"leve...
I'd like to run inspect on some object, but unfortunately it's either linking to some really big objects, or has a circular reference. That results in many pages of output.
Is there some way to limit the level of recursion that inspect is allowed to do?
...
I'm just beginning to work through SICP (on my own; this isn't for a class), and I've been struggling with Exercise 1.4 for a couple of days and I just can't seem to figure it out. This is the one where Alyssa re-defines if in terms of cond, like so:
(define (new-if predicate then-clause else-clause)
(cond (predicate then-clause)
...