[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: James McCartney <address@hidden>*Subject*: Re: can s-exprs represent a graph without eval?*From*: Neel Krishnaswami <address@hidden>*Date*: Thu, 19 Jun 2003 13:57:41 -0400*Cc*: <address@hidden>*In-reply-to*: <3317306E-A27B-11D7-8292-00039315CD46@io.com>*References*: <15530.208.204.155.241.1056034920.squirrel@la.znet.com><3317306E-A27B-11D7-8292-00039315CD46@io.com>*Sender*: address@hidden

James McCartney writes: > > S-exprs can represent trees of data easily. I am wondering if > s-exprs, or some other syntax, can be used to represent a graph just > on reading, without eval. > > I assume something simple could be done where you have a syntax to > bind symbols, and then access their bindings. Does Lisp do this > already? or is graph data just written as Lisp code and eval'ed? Yes, it can. The basic idea is that you can look at a graph as a tree with shared substructure. So you basically need a literal syntax for naming and referring to particular subtrees. So the infinite list (3 3 3 3 3 ...), which might be created with the following expression: (define infinite-list (let ((lst (cons 3 'null))) (set-cdr! lst lst) lst)) can also be written as (using the Scheme SRFI-38 notation, which I think is also used by Common Lisp): (define infinite-list #1=(3 . #1#)) #1= names the subtree, and #1# refers to it. Hope this helps. -- Neel Krishnaswami neelk@alum.mit.edu

**References**:**Re: I'd rather edit my spreadsheet with a text editor***From:*"Kevin Kelleher" <kkell@znet.com>

**can s-exprs represent a graph without eval?***From:*James McCartney <asynth@io.com>

- Prev by Date:
**Re: can s-exprs represent a graph without eval?** - Next by Date:
**can s-exprs represent a graph without eval?** - Previous by thread:
**Re: can s-exprs represent a graph without eval?** - Next by thread:
**can s-exprs represent a graph without eval?** - Index(es):