Questions tagged [anonymous-recursion]
Anonymous-recursion is recursion which does not explicitly call a function by name. This is usually done by calling the current function from within itself or by passing the current function as a callback to an other (named) function. Use this tag for questions directly related to this type of recursion only.
I'm doing an academic exercise (for personal growth). I want to find programming languages that allow you to define functions that are capable of accepting themselves (i.e., pointers to themselves) as ...
In The Little Schemer book, in Chapter 9, while building a length function for arbitrary long input, the following is suggested (on pages 170-171), that in the following code snippet (from page 168 ...
I am trying to create a big Vandermonde array of Func's. I can create a 4x3 system like this:
Func<double, double> vandermondeSystem =
x => x*Math.Pow(1, 0) + x*Math.Pow(1, ...
In the book The little schemer, we find this function that only supports lists with length smaller than or equal to 1:
(((lambda (mk-length) ; A.
I'm reading The Little Schemer and feel confused about the following code:
((null? l) 0)
(+ 1 (len (cdr l)))))))
I've been looking into how languages that forbid use-before-def and don't have mutable cells (no set! or setq) can nonetheless provide recursion. I of course ran across the (famous? infamous?) Y ...
I've spent a day reading page 166's length≤1 in the book The Little Schemer; there's the following code:
I am using a recursion function to convert my menus in a tree. The array I got from the database is:
 => stdClass Object (
[nav_group_id] => 1
[entity_id] => 1
Below are are functions and tests of anonymous recursion. The first one is true Y-combinator, looks fine and simple, but is quite slow. It takes 1000ms to execute 1 mln iterations. The second is quite ...
I was trying to solve the maximal subsequence sum problem and came up with a neato solution
msss :: (Ord a, Num a) => [a] -> a
msss = f 0 0
f gmax _  = gmax
f gmax lmax (x:xs) =
let g = ...
Note: This is kind of homework, kind of not - the end goal is to have a function that produces a powerset of a set of numbers supplied to the function as a list of numbers. I ahe a recursive version ...
I'm in a Scheme class and I was curious about writing a recursive function without using define. The main problem, of course, is that you cannot call a function within itself if it doesn't have a name....
Anonymous recursive PHP functions
I was wondering... Is it possible to do recursion with anonymous function?
Here is one example: ...
Consider the factorial function defined within a method body as a lambda expression and assigned to a variable:
Func<int, int> factfail = n =>
if (n == 0)
I surfed into this site a few days ago on "Anonymous Recursion in C#". The thrust of the article is that the following code will not work in C#:
Func<int, int> fib = n => n > 1 ? fib(n - ...