Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General question about concat #1

Open
fhalde opened this issue May 18, 2024 · 0 comments
Open

General question about concat #1

fhalde opened this issue May 18, 2024 · 0 comments

Comments

@fhalde
Copy link

fhalde commented May 18, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant