Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

List comprehensions for Lisp

1 view
Skip to first unread message

Sven-Olof Nystrom

unread,
Aug 27, 2003, 2:19:52 PM8/27/03
to

I've written an implementation of list comprehensions for Common
Lisp. My implementation also allows manipulation of hash tables and
arrays.

Documentation and source code can be downloaded at
<http://www.csd.uu.se/~svenolof/collect.tar.gz>.


Sven-Olof Nystrom

Jacek Generowicz

unread,
Aug 28, 2003, 4:37:21 AM8/28/03
to
Sven-Olof Nystrom <s...@h201n2fls305o851.telia.com> writes:

Taking the first example in your docs:

(collect (list) ((* x x))
(in (x) '(1 2 3 4 5 6 7 8)))

Is there a good reason for preferring this over

(collect list (* x x)
(in (x) '(1 2 3 4 5 6 7 8)))

In other words, do the parentheses in

<type-exp> ::= (nil) | (t) | (list) | (vector)

and those in <exp>, sereve any good purpose ?

Sven-Olof Nystrom

unread,
Aug 31, 2003, 4:47:19 AM8/31/03
to
Jacek Generowicz <jacek.ge...@cern.ch> writes:

Sure.

If we are only interested in working with lists and (one-dimensional)
arrays, the syntax you suggest is sufficient. However, if we want to
collect the result in a hash table, we want to say how the values with
a particular key are o be collected. For example:

(collect (hash-table (vector)) ((mod x 2) x)
(in (x) '(1 2 3 4 5 6)))

Here, all values with the same key are collected in a vector. The
collect expression generates a sequence of key-value pairs (the key
given by (mod x 2)). Thus, the result of the collect expression is
(under clisp):

#S(HASH-TABLE EQL (0 . #(2 4 6)) (1 . #(1 3 5)))

Sven-Olof

Eric Smith

unread,
Aug 31, 2003, 9:54:34 AM8/31/03
to
Sven-Olof Nystrom <s...@h201n2fls305o851.telia.com> wrote in message news:<m3bruab...@h201n2fls305o851.telia.com>...

> I've written an implementation of list comprehensions for Common

How is this fundamentally different from
the list functionality provided by standard
Common Lisp? If I use dolist, loop, the
various kinds of map, etc., instead of your
list comprehensions, am I missing something
fundamental without understanding what I'm
missing? Is there some kind of powerful
idea in this, or is it more of a convenience
for those who detest loop?

David Golden

unread,
Aug 31, 2003, 1:01:59 PM8/31/03
to
Sven-Olof Nystrom <s...@h201n2fls305o851.telia.com> wrote in message news:<m3bruab...@h201n2fls305o851.telia.com>...

Does this relate to the old SERIES stuff or is it something else?
http://www-2.cs.cmu.edu/Groups/AI/html/cltl/clm/node347.html

What's happened to http://series.sourceforge.net/ -
actual tarballs of series no longer seem to be there.

Sven-Olof Nystrom

unread,
Aug 31, 2003, 2:39:39 PM8/31/03
to
david....@oceanfree.net (David Golden) writes:

> Does this relate to the old SERIES stuff or is it something else?
> http://www-2.cs.cmu.edu/Groups/AI/html/cltl/clm/node347.html

No, it is not based on the series library (and I was not aware of the
series library before your post.)


Sven-Olof

0 new messages