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

Re: [Scheme-reports] Seeking review of sets and hash tables proposals



Per Bothner scripsit:

> What is not clear is what 'bag-for-each' should do when there are
> duplicates:
> Is the function called once for each "occurrence", or once for each
> "distinct value" (as given by the equivalence procedure).

Definitely once for each occurrence.  If we look at just fixnums, it's
clear that given a bag {1, 1, 1, 2, 2, 3} the bag-for-each procedure
invokes its function six times.

> OTOH, the latter is potentially much more efficient - you're basically
> asking for  "give me each value and the number of occurrences".
> You can get the number of occurrences with bag-count, or the
> procedure can be passed that as a 2nd parameter.

It's efficient, but it breaks the abstraction of a container with N
objects in it and without order.

-- 
Real FORTRAN programmers can program FORTRAN    John Cowan
in any language.  --Ed Post                     cowan@x

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports