RE: Will Fitzgerald <fitzgerald@neodesic.com>
Will Fitzgerald 15 Jan 1999 15:55 UTC
Here's another use of list-difference/ldiff, which is very similar to the
parse-signature example of Darius Bacon.
I'm working on a revision of the RAP System, a language for task execution, and
doing big parts of this in Scheme. A RAP index has the form:
(name in-var* [=> out-var*])
It's useful to have a list of just the name and in-vars, and:
(LIST-DIFFERENCE index (memq '=> index))
does just this.
Other examples I've seen of using LDIFF/LIST-DIFFERENCE tend to be for parsing
key word-like lists.
Best,
Will Fitzgerald
-----Original Message-----
>From: Darius Bacon [mailto:xxxxxx@accesscom.com]
Sent: Monday, January 11, 1999 2:27 PM
To: srfi-1@srfi.schemers.org
Subject: Re: Will Fitzgerald <xxxxxx@neodesic.com>
> Michael Sperber <xxxxxx@Informatik.Uni-Tuebingen.De> writes:
> >>>>>> "Will" == Will Fitzgerald <xxxxxx@neodesic.com> writes:
> >
> >Will> May I suggest the following addition to the SRFI-1 list library,
> >Will> Common Lisp's LDIFF:
> >
> >Will> I think a reasonable definition is:
> >Will> [...]
> >[...]
> >Could you suggest possible uses for this procedure?
Here's a fairly trivial use taken from a real program:
(define parse-signature
(lambda (spec)
(let* ((mid (memq '- spec))
(in (list-difference spec mid))
(out (cdr mid)))
(make-signature in out))))
And here's another:
(define (butlast L)
(list-difference L (last-pair L)))
But groveling through my source directories reveals fewer instances of
list-difference than I expected.
-Darius