# Re: cons cells

*From*: "Pascal J. Bourguignon" <pjb@xxxxxxxxxxxxxxxxx>*Date*: Tue, 05 Apr 2011 04:03:41 +0200

Peter Keller <psilord@xxxxxxxxxxx> writes:

Andrew Reilly <areilly---@xxxxxxxxxxxxxx> wrote:

On Mon, 04 Apr 2011 16:14:59 -0700, TheFlyingDutchman wrote:

Where is the dotted pair(s)?

Here's something more obviously tree-shaped (in scheme, but I'm sure the

same thing works similarly in CL) that I've used from time to time:

(define (maptree f t) ; apply f to leaves of tree t, returning a new

tree of same shape as t

(cond

((null? t) t)

((pair? t) (cons (maptree f (car t)) (maptree f (cdr t))))

(else (f t))))

Out of curiosity, how would you do a mapgraph that preserves the graph

structure?

If the mapping functions preserve it, then it's trivial:

(defun mapgraph (node-fun edge-fun graph)

(make-graph :nodes (mapcar (function node-fun) (graph-nodes graph))

:edges (mapcar (function edge-fun) (graph-edges graph))))

But in all probability, node-fun or edge-fun won't be bijections, so

there's little point in defining such a mapgraph function.

--

__Pascal Bourguignon__ http://www.informatimago.com/

A bad day in () is better than a good day in {}.

.

**References**:**Re: cons cells***From:*Don Geddis

**Re: cons cells***From:*TheFlyingDutchman

**Re: cons cells***From:*Don Geddis

**Re: cons cells***From:*TheFlyingDutchman

**Re: cons cells***From:*Ankur

**Re: cons cells***From:*TheFlyingDutchman

**Re: cons cells***From:*Drew Crampsie

**Re: cons cells***From:*TheFlyingDutchman

**Re: cons cells***From:*Andrew Reilly

**Re: cons cells***From:*Peter Keller

- Prev by Date:
**Re: cons cells** - Next by Date:
**Re: cons cells** - Previous by thread:
**Re: cons cells** - Next by thread:
**Re: cons cells** - Index(es):