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)
  (cond
    ((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          http://www.ccil.org/~cowan        [email protected]
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

_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to