Question: Is there a way to make the something like the following code work?

```
add = lambda n: (yield n) or add(n+1)

```

(answers don't need to be in functional style)

Answer: 
```
def add(n):
    yield n
    for m in add(n+1):
        yield m

```

With recursive generators it's easy to build elaborate backtrackers:

```
def resolve(db, goals, cut_parent=0):
    try:
        head, tail = goals[0], goals[1:]
    except IndexError:
        yield {}
        return
    try:
        predicate = (
            deepcopy(clause)
                for clause in db[head.name]
                    if len(clause) == len(head)
        )
    except KeyError:
        return
    trail = []
    for clause in predicate:
        try:
            unify(head, clause, trail)
            for each in resolve(db, clause.body, cut_parent + 1):
                for each in resolve(db, tail, cut_parent):
                    yield head.subst
        except UnificationFailed:
            continue
        except Cut, cut:
            if cut.parent == cut_parent:
                raise
            break
        finally:
            restore(trail)
    else:
        if is_cut(head):
            raise Cut(cut_parent)

...

for substitutions in resolve(db, query):
    print substitutions

```

This is a Prolog engine implemented by a recursive generator. db is a dict representing a Prolog database of facts and rules. unify() is the unification function that creates all substitutions for the current goal and appends the changes to the trail, so they can be undone later. restore() does the undoing, and is\_cut() tests if the current goal is a '!', so that we can do branch pruning.
I'm not sure of the intent of "yield(n) or add(n+1)", but recursive generators are certainly possible. You might want to read the link below to get a grip on what's possible, in particular the section titled "Recursive Generators".

* [Python Generator Tricks](http://linuxgazette.net/100/pramode.html)