From: Kevin Ryde <user42@zip.com.au>
Cc: guile-user@gnu.org
Subject: Re: association list bug? -- version 1.6.4
Date: Wed, 16 Nov 2005 08:41:11 +1100 [thread overview]
Message-ID: <87lkzpoah4.fsf@zip.com.au> (raw)
In-Reply-To: <437A32DA.1000502@fastmail.fm> (Jon Wilson's message of "Tue, 15 Nov 2005 13:11:22 -0600")
Jon Wilson <j85wilson@fastmail.fm> writes:
>
> which seems to suggest (incorrectly, obviously) that the arguments to
> both assoc and assoc-ref should be the same. Perhaps, given that it
> seems that a fairly large number of people have misread the manual and
> gotten confused about this, it would be helpful to add a phrase
> explicitly pointing out that the argument order is reversed.
I'll change the section to something like below. Both shorter and
clearer I think.
5.6.11.3 Retrieving Alist Entries
.................................
`assq', `assv' and `assoc' find the entry in an alist for a given key,
and return the `(KEY . VALUE)' pair. `assq-ref', `assv-ref' and
`assoc-ref' do a similar lookup, but return just the VALUE.
-- Scheme Procedure: assq key alist
-- Scheme Procedure: assv key alist
-- Scheme Procedure: assoc key alist
-- C Function: scm_assq (key, alist)
-- C Function: scm_assv (key, alist)
-- C Function: scm_assoc (key, alist)
Return the first entry in ALIST with the given KEY. The return is
the pair `(KEY . VALUE)' from ALIST. If there's no matching entry
the return is `#f'.
`assq' compares keys with `eq?', `assv' uses `eqv?' and `assoc'
uses `equal?'.
-- Scheme Procedure: assq-ref alist key
-- Scheme Procedure: assv-ref alist key
-- Scheme Procedure: assoc-ref alist key
-- C Function: scm_assq_ref (alist, key)
-- C Function: scm_assv_ref (alist, key)
-- C Function: scm_assoc_ref (alist, key)
Return the value from the first entry in ALIST with the given KEY,
or `#f' if there's no such entry.
`assq-ref' compares keys with `eq?', `assv-ref' uses `eqv?' and
`assoc-ref' uses `equal?'.
Notice these functions have the KEY argument last, like other
`-ref' functions, but this is opposite to what what `assq' etc
above use.
When the return is `#f' it can be either KEY not found, or an
entry which happens to have value `#f' in the `cdr'. Use `assq'
etc above if you need to differentiate these cases.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
next prev parent reply other threads:[~2005-11-15 21:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-15 2:00 association list bug? -- version 1.6.4 Jon Wilson
2005-11-15 5:01 ` Tomas Zerolo
2005-11-15 16:49 ` Jon Wilson
2005-11-15 17:21 ` Ludovic Courtès
2005-11-15 19:11 ` Jon Wilson
2005-11-15 21:41 ` Kevin Ryde [this message]
2005-11-16 0:00 ` Jon Wilson
2005-11-17 16:10 ` Thien-Thi Nguyen
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=87lkzpoah4.fsf@zip.com.au \
--to=user42@zip.com.au \
--cc=guile-user@gnu.org \
/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).