Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

grep me no patterns and I'll tell you no lines.


devel / comp.lang.lisp / (loop initially ... getting non-ANSI CL warning

SubjectAuthor
* (loop initially ... getting non-ANSI CL warningRobert L.
`- Re: (loop initially ... getting non-ANSI CL warningRobert L.

1
(loop initially ... getting non-ANSI CL warning

<sug4ro$2rk$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16842&group=comp.lang.lisp#16842

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!aMAqIjoFp9E5xuSVbxlMJA.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: (loop initially ... getting non-ANSI CL warning
Date: Tue, 15 Feb 2022 12:04:09 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <sug4ro$2rk$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="2932"; posting-host="aMAqIjoFp9E5xuSVbxlMJA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Tue, 15 Feb 2022 12:04 UTC

> * (Mirko.Vukovic @ gmail.com) Wrote on Wed, 23 Jan 2008 08:41:15 -0800 (PST):
> | Second, I was not clear in my original post, but Ken caught it: I am
> | parsing an ordered list.
> [...]
> | (defun collect-duplicates (list)
> | (loop
> | for a in list
> | for b in (cdr list)
> | when (equal a b)
> | collect b))
> |
> | It eliminates the (setf ...), and I must admit, the setf just did not
> | look right in the loop. But I could not think of another way of doing
> | it.
>
> Note that you can use LOOP destructuring like this:
> (loop for (a b) on list when (equal a b) collect b)
>
> To fix the duplicate elements in the returned list, you can use
> an extra loop variable like this.
>
> (defun collect-duplicates (list)
> "LIST is an ordered list without null elements."
> (loop for prev = NIL then a
> for (a b) on list
> when (equal a b) unless (equal prev a) collect a))

(use srfi-1) ;; span for Gauche Scheme
or
(require srfi/1) ;; span for Racket
(require srfi/26) ;; cut for Racket

(define (dups xs)
(if (null? xs)
'()
(let-values (((a b) (span (cut equal? <> (car xs)) xs)))
(if (pair? (cdr a))
(cons (car a) (dups b))
(dups b)))))

(dups '(a a a b c c c d d d d d))
===>
(a c d)

Re: (loop initially ... getting non-ANSI CL warning

<sug68r$nnn$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16843&group=comp.lang.lisp#16843

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!aMAqIjoFp9E5xuSVbxlMJA.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: Re: (loop initially ... getting non-ANSI CL warning
Date: Tue, 15 Feb 2022 12:28:12 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <sug68r$nnn$1@gioia.aioe.org>
References: <sug4ro$2rk$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="24311"; posting-host="aMAqIjoFp9E5xuSVbxlMJA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Tue, 15 Feb 2022 12:28 UTC

On 2/15/2022, Robert L. wrote:

> > * (Mirko.Vukovic @ gmail.com) Wrote on Wed, 23 Jan 2008 08:41:15 -0800 (PST):
> > > Second, I was not clear in my original post, but Ken caught it: I am
> > > parsing an ordered list.
> > [...]
> > > (defun collect-duplicates (list)
> > > (loop
> > > for a in list
> > > for b in (cdr list)
> > > when (equal a b)
> > > collect b))
> > >
> > > It eliminates the (setf ...), and I must admit, the setf just did not
> > > look right in the loop. But I could not think of another way of doing
> > > it.
> >
> > Note that you can use LOOP destructuring like this:
> > (loop for (a b) on list when (equal a b) collect b)
> >
> > To fix the duplicate elements in the returned list, you can use
> > an extra loop variable like this.
> >
> > (defun collect-duplicates (list)
> > "LIST is an ordered list without null elements."
> > (loop for prev = NIL then a
> > for (a b) on list
> > when (equal a b) unless (equal prev a) collect a))
>
> (use srfi-1) ;; span for Gauche Scheme
> or
> (require srfi/1) ;; span for Racket
> (require srfi/26) ;; cut for Racket
>
> (define (dups xs)
> (if (null? xs)
> '()
> (let-values (((a b) (span (cut equal? <> (car xs)) xs)))
> (if (pair? (cdr a))
> (cons (car a) (dups b))
> (dups b)))))
>
> (dups '(a a a b c c c d d d d d))
> ===>
> (a c d)

Gauche Scheme or Racket

(require srfi/1) ;; delete-duplicates for Racket

(define (dups xs)
(delete-duplicates
(filter-map (lambda (a b) (and (equal? a b) b)) xs (cdr xs))))


devel / comp.lang.lisp / (loop initially ... getting non-ANSI CL warning

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor