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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add contains-value? function #520
Conversation
Also the current implementation is not working for maps:
I would suggest to solve this problem with existing Phel functions only. Maybe the |
Isn't the |
That's a good idea. Actually changing the function to this helps a lot: (defn contains-value?
"Returns true if value is present in the given collection, otherwise returns false."
[coll val]
(if (empty? coll)
false
(not (nil? (find |(= $ val) coll))))) And all the tests that I wrote pass, but not these two: (is (false? (contains-value? (set 1) 2)))
(is (true? (contains-value? (set 1) 1))) Any idea why are only these two tests failing? 馃 |
I would suggest to wrap
|
@jenshaase, thanks! Code updated 馃憣馃徎 |
Could you add tests for maps? |
Sure thing, @jenshaase. Done. |
ed0bf96
to
5456a8b
Compare
馃 Background
I think it would be practical if we have a function that checks if a value is inside a collection. Similar as the
contains?
馃馃敄 Changes
contains-value?
function