Subject: Re: Matching and unpacking arbitrary data structures
From: (Rob Warnock)
Date: Fri, 28 Dec 2007 04:51:45 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
TomSW  <> wrote:
| I've recently started programming Lisp at work, and often find myself
| having to unpack a data structure (eg, a plist containing plists
| containing lists) and then filter and process it as a list.
| It strikes me this is a kind of data query, and I was wondering if
| there was a neat way to do it, a kind of SQL for objects. ...

Have you bought/read Peter Seibel's "Practical Common Lisp" yet?
It sounds like the simple in-memory database shown in Chapter 3
might be just what you're looking for. It starts from scratch and
works up to being able to write SQL-ish queries such as this one:

    CL-USER> (select (where :title "Give Us a Break" :ripped t))
    ((:TITLE "Give Us a Break" :ARTIST "Limpopo" :RATING 10 :RIPPED T))

Chapter 27 takes this further, introducing multiple tables, schema
definitions, and a richer SELECT operator [that also returns tables
as its results, which can be fed to other SELECTs, etc.], e.g.:

    ;; Select a sorted list of artists with songs in the genre "Rock"
      :columns :artist
      :from *mp3s*
      :where (matching *mp3s* :genre "Rock")
      :distinct t
      :order-by :artist)


p.s. Oh, o.k., you can also read Chapters 3 & 27 here:

But buy the hardcopy book anyway. It's worth it.

Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607