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

Re: count



Bruce Hoult wrote:
...
> It seems stange to me that Dylan has every? and any?, but not count,
> given that every? and any? can both be efficiently created from count,
> as count(coll, pred) >= 1  and  count(coll, pred) = coll.size.

  Not.  Check the DRM for every? ....
   "If all the collecitons are sequences... In all cases, every? stops
    on the first false value returned by function." 

  I suspect an any? will likewise short-circuit. [ Someone may actually
  depend upon a predicate that has a side-effects. Not that should be
  common, but should it be "disallowed"?  ] 

  That's a mostly equivalent implementation. It isn't the most effiecent.
  Think sequences with 1,000,000 elements in it where the first element
  tests false; why add up that many zeros? 


Lyman



References: