This page is part of the web mail archives of SRFI 113 from before July 7th, 2015. The new archives for SRFI 113 contain all messages, not just those from before July 7th, 2015.
Kevin Wortman scripsit:
Bag-delete-all doesn't remove all instances of the objects in the list,
> How about something like this (untested pseudocode) for alist->bag!:
>
> (define (alist->bag! bag alist)
> (bag-delete-all! bag (map car alist))
only one instance: it means "all in list", not "all copies". Maybe the
name should be changed? And by the same token, maybe there should be
bag operations to delete all copies of some object(s)?
That's what I said it should do, but on reflection it's not quite right.
> (for-each (lambda (pair)
> (unless (bag-contains? bag (car pair))
> (bag-increment! bag (car pair) (cdr pair))))
> alist))
If the bag is {a, a, a} and the a-list says ((a . 1) (a . 2)), I think
we should end up with {a, a, a, a} as a result of the (a . 1), and the
(a . 2) should be ignored.
Maybe this means that alist->bag! doesn't really make sense. Thoughts?
Principles. You can't say A is made of B or vice versa.
All mass is interaction. --Richard Feynman