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

re: Stupid question (creating a sequence of *different* objects)

17 views
Skip to first unread message

WJ

unread,
May 22, 2012, 12:41:41 AM5/22/12
to
Marco Antoniotti wrote:

> I know how to do it. I a just wondering what people feel would be a
> good interface (in the spirit of the PARTITION/SPLIT-SEQUENCE and
> EXTREMIZE debate).
>
> I often find myself doing things like
>
> (loop for i from 0 to N collect (make-something))
>
> just because
>
> (make-list N :initial-element (make-something))
>
> fills the list with EQ elements. (The same applies to MAKE-ARRAY, of
> course).
>
> I was thinking to write something along the lines of
>
> (defun make-list-collecting (n &key
> (element-constructor (lambda () nil)))
> (loop for i from 0 below N collect (funcall f)))


Racket:

(apply eq? (make-list 2 (list 'u)))
=> #t

(apply eq? (build-list 2 (thunk* (list 'u))))
=> #f

Marco Antoniotti

unread,
May 22, 2012, 8:57:10 AM5/22/12
to
Wow. It appears that old posts lose their readability.

(Or is it the reader who does not have such ability?) ]-}

Cheers
--
MA
0 new messages