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

Re: Proposal: count

This page is part of the web mail archives of SRFI 101 from before July 7th, 2015. The new archives for SRFI 101 contain all messages, not just those from before July 7th, 2015.

Taylor R Campbell wrote:
   Date: Sun, 20 Sep 2009 18:58:38 -0400
   From: David Van Horn <dvanhorn@xxxxxxxxxxx>

While `length' gives you number of pairs in a list, it's also useful to determine the number of pairs in a (potentially) improper list.

When might one want to do this?

It's useful for bounds checking. Actually, I think a more useful operation would be something like:

   (lenth<=? obj k) -> bool

Which would be the same as (<= (count obj) k). This operation would take O(min(log(count obj),log k)). It's important to note that obj need not be a list.