guile-user
[Top][All Lists]
Advanced

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

Re: association list bug? -- version 1.6.4


From: Kevin Ryde
Subject: Re: association list bug? -- version 1.6.4
Date: Wed, 16 Nov 2005 08:41:11 +1100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

Jon Wilson <address@hidden> 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.




reply via email to

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