LAST CALL for SRFI-113, Sets and bags John Cowan (16 Aug 2014 00:23 UTC)
Re: LAST CALL for SRFI-113, Sets and bags Michael Sperber (16 Aug 2014 14:11 UTC)
Re: LAST CALL for SRFI-113, Sets and bags John Cowan (16 Aug 2014 18:16 UTC)
Re: LAST CALL for SRFI-113, Sets and bags Per Bothner (16 Aug 2014 20:33 UTC)
Broken SRFI 113 title John Cowan (16 Aug 2014 23:19 UTC)
Re: LAST CALL for SRFI-113, Sets and bags Kevin Wortman (18 Aug 2014 22:11 UTC)
Re: LAST CALL for SRFI-113, Sets and bags John Cowan (18 Aug 2014 22:38 UTC)
Re: LAST CALL for SRFI-113, Sets and bags Per Bothner (18 Aug 2014 22:42 UTC)
Re: LAST CALL for SRFI-113, Sets and bags Kevin Wortman (18 Aug 2014 22:57 UTC)
Re: LAST CALL for SRFI-113, Sets and bags John Cowan (19 Aug 2014 00:26 UTC)
Re: LAST CALL for SRFI-113, Sets and bags Kevin Wortman (19 Aug 2014 17:57 UTC)
Re: LAST CALL for SRFI-113, Sets and bags John Cowan (19 Aug 2014 18:18 UTC)
Re: LAST CALL for SRFI-113, Sets and bags Kevin Wortman (19 Aug 2014 21:15 UTC)
Re: LAST CALL for SRFI-113, Sets and bags John Cowan (19 Aug 2014 22:20 UTC)
Re: LAST CALL for SRFI-113, Sets and bags Kevin Wortman (20 Aug 2014 06:44 UTC)
Re: LAST CALL for SRFI-113, Sets and bags John Cowan (20 Aug 2014 13:28 UTC)

Re: LAST CALL for SRFI-113, Sets and bags John Cowan 19 Aug 2014 22:20 UTC

Kevin Wortman scripsit:

> How about something like this (untested pseudocode) for alist->bag!:
>
> (define (alist->bag! bag alist)
>   (bag-delete-all! bag (map car alist))

Bag-delete-all doesn't remove all instances of the objects in the list,
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)?

>   (for-each (lambda (pair)
>                   (unless (bag-contains? bag (car pair))
>                     (bag-increment! bag (car pair) (cdr pair))))
>                 alist))

That's what I said it should do, but on reflection it's not quite right.
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?

--
John Cowan          http://www.ccil.org/~cowan        xxxxxx@ccil.org
Principles.  You can't say A is made of B or vice versa.
All mass is interaction.  --Richard Feynman