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
Modify dissoc-in to accept variable args #25
Conversation
You need to keep the original |
Also, is |
Why do you say it? |
In your changes, you've removed the |
ae43e27
to
b1fed1a
Compare
With the following element old dissoc in -> 0.005182, 0.005265, 0.005219, 0.005197, 0.005223 With the following element new dissoc in with reduce -> 0.012029, 0.011852, 0.011736, 0.011868, 0.011746 |
Thanks for the tests. It looks like it's more performant to use a loop-recur, though if you could use Criterium's |
src/medley/core.cljc
Outdated
(dissoc m k)) | ||
m)) | ||
([m ks & rest-ks] | ||
(loop [m m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure you can get rid of this loop
and just recur
over the function body. Take a look at dissoc for reference.
I think you've misunderstood me. I was suggesting something like: (defn dissoc-in
([m ks]
(if-let [[k & ks] (seq ks)]
(if (seq ks)
(let [v (dissoc-in (get m k) ks)]
(if (empty? v)
(dissoc m k)
(assoc m k v)))
(dissoc m k))
m))
([m ks & kss]
(if-let [[ks' & kss] (seq kss)]
(recur (dissoc-in m ks) ks' kss)
(dissoc-in m ks)))) |
b24927e
to
d32438f
Compare
Thanks! Could you squash your commits? Perhaps into something like:
|
d32438f
to
25c4103
Compare
done |
Thanks! Can you update the commit message, too? |
25c4103
to
13e520c
Compare
done |
This pr solves issue #23
Through this change we can use the dissoc-in function like in the following example