[Top][All Lists]

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

Re: [Chicken-users] CHICKEN 4.9.0rc1 is available

From: John Cowan
Subject: Re: [Chicken-users] CHICKEN 4.9.0rc1 is available
Date: Sun, 4 May 2014 14:57:37 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

Andy Bennett scripsit:

> We also had to fix the dropbox egg where it calls alist-ref. Some time
> after CHICKEN 4.7.0 it became mandatory to pass a well formed alist to
> alist-ref but we were relying on it returning the default value.

For the record, it is an error in all versions of Scheme to pass
anything other than a (proper) list of pairs to the alist procedures,
so the effect of doing so is entirely implementation-defined.  Here is
a suitable predicate:

(define (alist? obj)
    ((null? obj) #t)
    ((not (pair? obj)) #f)
    ((not (pair? (car obj))) #f)
    (else (alist? (cdr obj)))))

It is O(n), which is the best you can do.

John Cowan        address@hidden
Rather than making ill-conceived suggestions for improvement based on
uninformed guesses about established conventions in a field of study with
which familiarity is limited, it is sometimes better to stick to merely
observing the usage and listening to the explanations offered, inserting
only questions as needed to fill in gaps in understanding. --Peter Constable

reply via email to

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