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

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



On 05/25/2013 06:00 PM, John Cowan wrote:
> Per Bothner scripsit:
>
>>>     If a bag's notion of element equality only
>>>     takes into account a part of each element
>>>     and ignores the rest of the element,
>>>     keeping a count instead of the elements
>>>     themselves would lose information.
>>
>> I don't the think the bag API supports this.  I.e. using
>> a bag will also lose information, unless the bag API is
>> clearly specified to support this use case.  And I don't
>> believe it does.
>
> To clarify this, I have added the following sentence to the abstract:
>
> 	However, if two elements that are equal in the sense of the
> 	equivalence procedure, but not in the sense of <code>eqv?</code>,
> 	are both included, it is not guaranteed that they will remain
> 	distinct when retrieved from the bag.

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).

The former potentially allows you to handle the different values
that are equivalent but not eqv?; the latter does not.
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.
-- 
	--Per Bothner
per@x   http://per.bothner.com/

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