Jacek Generowicz <jacek.generow
...@cern.ch> writes:
> Sven-Olof Nystrom <s
...@h201n2fls305o851.telia.com> writes:
> > 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>.
> 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 ?
Sure. 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)))