help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : Determine whether a list is an alist


From: Drew Adams
Subject: RE: [External] : Determine whether a list is an alist
Date: Thu, 13 Jul 2023 16:07:49 +0000

> > In many (most?) cases you don't really care
> > whether each element of the list is a cons - you
> > just want to retrieve the first match, and you
> > only want to traverse then entire list if you
> > have to (i.e., when there's no match or the last
> > element matches), and you don't want to traverse
> > it more than once.
> 
> If I want to print the alist in (Key . Value) way, how would one skip
> extraneous (non-cons) list entries ?

`dolist' is your friend.

Printing is a side-effect thingie.  `dolist' is
a natural for iterating over a list, performing
side effects.  Just test each list element and
do what you want with it - that can include
doing nothing with it.  "Extraneous" is in the
eye of the caller-beholder.

This is no different from C, Fortran, assembler,
etc., except that Lisp gives you easy to use
lists and list iterators, ready-made.

LISP: LISt Processing.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]