Multisets with duplicates?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Multisets with duplicates?

Stephen R. van den Berg
This seems like a bug:

Pike v8.1 release 13 running Hilfe v3.5 (Incremental Pike Frontend)
> (<"foo", "bar">) | (<"some", "bar">);
(1) Result: (< /* 3 elements */
              "bar",
              "foo",
              "some"
            >)
> (<"foo", "bar">) + (<"some", "bar">);
(2) Result: (< /* 4 elements */
              "bar",
              "bar",
              "foo",
              "some"
            >)
>

--
Stephen.
Reply | Threaded
Open this post in threaded view
|

Multisets with duplicates?

Martin Nilsson (Coppermist) @ Pike (-) developers forum
How do you figure?  To me it looks like it's working exactly as
intended (| gives set semantics, + gives multiset semantics).
Reply | Threaded
Open this post in threaded view
|

Re: Multisets with duplicates?

Stanislaw Klekot
In reply to this post by Stephen R. van den Berg
On Fri, Mar 12, 2021 at 10:40:03AM +0100, Stephen R. van den Berg wrote:

> This seems like a bug:
>
> Pike v8.1 release 13 running Hilfe v3.5 (Incremental Pike Frontend)
> > (<"foo", "bar">) | (<"some", "bar">);
> (1) Result: (< /* 3 elements */
>               "bar",
>               "foo",
>               "some"
>             >)
> > (<"foo", "bar">) + (<"some", "bar">);
> (2) Result: (< /* 4 elements */
>               "bar",
>               "bar",
>               "foo",
>               "some"
>             >)
> >

Note that the data type's name is *multi*set, so a *set* with
*duplicates*. This behaviour is exactly what you should to expect after
hearing the name.

  https://en.wikipedia.org/wiki/Multiset

--
Stanislaw Klekot
Reply | Threaded
Open this post in threaded view
|

Re: Multisets with duplicates?

Stephen R. van den Berg
Stanislaw Klekot wrote:
>On Fri, Mar 12, 2021 at 10:40:03AM +0100, Stephen R. van den Berg wrote:
>> This seems like a bug:

>Note that the data type's name is *multi*set, so a *set* with
>*duplicates*. This behaviour is exactly what you should to expect after
>hearing the name.

Ah well, maybe I never thought twice about it.
I always assumed it does not allow duplicate members (just like the
keyspace of a mapping).

Nevermind.
--
Stephen.