From: Kevin Ryde <user42@zip.com.au>
Subject: doc proper-list? etc
Date: Thu, 27 Jan 2005 11:20:56 +1100 [thread overview]
Message-ID: <874qh3bu3b.fsf@zip.com.au> (raw)
I've tried to clarify proper-list? and friends a bit, in particular to
note how they partition all objects.
-- Scheme Procedure: proper-list? obj
Return `#t' if OBJ is a proper list, or `#f' otherwise. This is
the same as the core `list?' (*note List Predicates::).
A proper list is a list which ends with the empty list `()' in the
usual way. The empty list `()' itself is a proper list too.
(proper-list? '()) => #t
(proper-list? '(1 2 3)) => #t
-- Scheme Procedure: circular-list? obj
Return `#t' if OBJ is a circular list, or `#f' otherwise.
A circular list is a list where at some point the `cdr' refers
back to a previous pair in the list (either the start or some later
point), so that following the `cdr's takes you around in a circle,
with no end.
(define x (list 1 2 3 4))
(set-cdr! (last-pair x) (cddr x))
x => (1 2 3 4 3 4 3 4 ...)
(circular-list? x) => #t
-- Scheme Procedure: dotted-list? obj
Return `#t' if OBJ is a dotted list, or `#f' otherwise.
A dotted list is a list where the `cdr' of the last pair is not
the empty list `()'. Any non-pair OBJ is also considered a dotted
list, one with length zero.
(dotted-list? '(1 2 . 3)) => #t
(dotted-list? 99) => #t
It will be noted that any Scheme object passes exactly one of the
above three tests `proper-list?', `circular-list?' and `dotted-list?'.
Non-lists are `dotted-list?', finite lists are either `proper-list?' or
`dotted-list?', and infinite lists are `circular-list?'.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
reply other threads:[~2005-01-27 0:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874qh3bu3b.fsf@zip.com.au \
--to=user42@zip.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).