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

Re: Is a new CL standard possible?

143 views
Skip to first unread message

WJ

unread,
Dec 9, 2013, 7:02:56 PM12/9/13
to
Pascal J. Bourguignon wrote:

> Indeed, LOOP is very basic and already provides all you want:
>
> (let ((list '(a :foo b :bar c))
> (collect '()))
> (loop
> (unless list (return collect))
> (let ((elt (pop list)))
> (case elt
> ((:foo :bar) (do-something-with elt))
> (t (push elt collect))))))
>
> prints:
> (DONE SOMETHING WITH :FOO)
> (DONE SOMETHING WITH :BAR)
>
> --> (C B A)

Clojure:

(let [stuff '(a :foo b :bar c)]
(reduce
(fn [accum elt]
(case elt
(:foo :bar) (do (println elt) accum)
(conj accum elt)))
[]
stuff))

-->
:foo
:bar
[a b c]

WJ

unread,
Jun 21, 2014, 9:42:31 PM6/21/14
to
elisp:

(require 'dash)

(--filter
(if (member it '(:foo :bar))
(progn (message "Did something with %s." it) nil)
t)
'(a :foo b :bar c))

Did something with :foo.
Did something with :bar.
(a b c)

WJ

unread,
Mar 25, 2015, 1:29:35 AM3/25/15
to
WJ wrote:

> Pascal J. Bourguignon wrote:
>
> > Indeed, LOOP is very basic and already provides all you want:
> >
> > (let ((list '(a :foo b :bar c))
> > (collect '()))
> > (loop
> > (unless list (return collect))
> > (let ((elt (pop list)))
> > (case elt
> > ((:foo :bar) (do-something-with elt))
> > (t (push elt collect))))))
> >
> > prints:
> > (DONE SOMETHING WITH :FOO)
> > (DONE SOMETHING WITH :BAR)
> >
> > --> (C B A)

Gauche Scheme:

(let1 stuff '(a :foo b :bar c)
(filter
(lambda (elt)
(when (member elt '(:foo :bar))
(print #"Did something with ~elt")
#f))
stuff))

Did something with foo
Did something with bar
(a b c)
0 new messages