Skip to content

General question about concat #1

Description

@fhalde

Hi, I came across this implementation of yours from here

Amazing article! For my understanding, I decided to write it in Clojure but fumbled upon one aspect of concat

A multiset can have repetitive keys

[('cat', 4), ('dog', 2), ('elephant', -4), ('elephant', 4)]

When implementing concat, how do I decide which keys to merge it against? For e.g.

[('cat', 4), ('dog', 2), ('elephant', -4), ('elephant', 4)].concat([('elephant', 1)])

has 3 possibilities

#1 [('cat', 4), ('dog', 2), ('elephant', -3), ('elephant', 4)]
#2 [('cat', 4), ('dog', 2), ('elephant', -4), ('elephant', 5)]
#3 [('cat', 4), ('dog', 2), ('elephant', -4), ('elephant', 4), ('elephant', 1)]

Now, I know it doesn't matter since consolidating them results in the same outcome, so what would be my basis to make a choice?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions