Why does (condp contains? (:symbols xx) :a (prn “yes”)) give contains? not supported on type: clojure.lang.Keyword error?Why does Clojure have “keywords” in addition to “symbols”?How does Clojure ^:const work?Why does Clojure distinguish between symbols and vars?def'ine a value with a dynamic nameCryptic Clojure error: java.lang.UnsupportedOperationException: nth not supported on this type: SymbolWhat does this clojure.core.typed type error mean?Why does this midje test fail?How to send a postwalk-replace function to an agentHow to obtain Uppercase string from a sentence in clojure?Why does clojure attempt to resolve this symbol?
How can this Stack Exchange site have an animated favicon?
Safe to use 220V electric clothes dryer when building has been bridged down to 110V?
Why does (inf + 0j)*1 evaluate to inf + nanj?
Draw a table of clocks on a plane
Why did UK NHS pay for homeopathic treatments?
What exactly did this mechanic sabotage on the American Airlines 737, and how dangerous was it?
Excel Solver linear programming - Is it possible to use average of values as a constraint without #DIV/0! errors or sacrificing linearity?
What are the consequences of high orphan block rate?
Clear text passwords in Unix
Why did the Soviet Union not "grant" Inner Mongolia to Mongolia after World War Two?
Do we know the situation in Britain before Sealion (summer 1940)?
Quick Yajilin Puzzles: Scatter and Gather
A food item only made possible by time-freezing storage?
Would you write key signatures for non-conventional scales?
Problem using sed back reference
Lost Update Understanding
Do wheelchair-accessible aircraft exist?
Does the Horizon Walker ranger's Planar Warrior feature bypass resistance to non-magical attacks?
Could Apollo astronauts see city lights from the moon?
Can I enter the UK without my husband if we said we'd travel together in our visa application?
Can my former employer sue me if I don't give them the photos I took (taking pictures was not part of my job description)?
Reorder a matrix, twice
What does ubuntu server show on display under normal operation?
Is a Middle Name a Given Name?
Why does (condp contains? (:symbols xx) :a (prn “yes”)) give contains? not supported on type: clojure.lang.Keyword error?
Why does Clojure have “keywords” in addition to “symbols”?How does Clojure ^:const work?Why does Clojure distinguish between symbols and vars?def'ine a value with a dynamic nameCryptic Clojure error: java.lang.UnsupportedOperationException: nth not supported on this type: SymbolWhat does this clojure.core.typed type error mean?Why does this midje test fail?How to send a postwalk-replace function to an agentHow to obtain Uppercase string from a sentence in clojure?Why does clojure attempt to resolve this symbol?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to use condp for a problem.
This is what I am trying to checking using condp.
(def xx :symbols :a 1)
(contains? (:symbols xx) :a)
true
But I get this error
(condp contains? (:symbols xx) :a (prn "yes"))
IllegalArgumentException contains? not supported on type:
clojure.lang.Keyword clojure.lang.RT.contains
clojure
add a comment
|
I want to use condp for a problem.
This is what I am trying to checking using condp.
(def xx :symbols :a 1)
(contains? (:symbols xx) :a)
true
But I get this error
(condp contains? (:symbols xx) :a (prn "yes"))
IllegalArgumentException contains? not supported on type:
clojure.lang.Keyword clojure.lang.RT.contains
clojure
1
Please update your question with the value ofxx
– Alan Thompson
Mar 28 at 18:09
add a comment
|
I want to use condp for a problem.
This is what I am trying to checking using condp.
(def xx :symbols :a 1)
(contains? (:symbols xx) :a)
true
But I get this error
(condp contains? (:symbols xx) :a (prn "yes"))
IllegalArgumentException contains? not supported on type:
clojure.lang.Keyword clojure.lang.RT.contains
clojure
I want to use condp for a problem.
This is what I am trying to checking using condp.
(def xx :symbols :a 1)
(contains? (:symbols xx) :a)
true
But I get this error
(condp contains? (:symbols xx) :a (prn "yes"))
IllegalArgumentException contains? not supported on type:
clojure.lang.Keyword clojure.lang.RT.contains
clojure
clojure
edited Mar 28 at 18:25
Snehaa Ganesan
asked Mar 28 at 17:58
Snehaa GanesanSnehaa Ganesan
3409 bronze badges
3409 bronze badges
1
Please update your question with the value ofxx
– Alan Thompson
Mar 28 at 18:09
add a comment
|
1
Please update your question with the value ofxx
– Alan Thompson
Mar 28 at 18:09
1
1
Please update your question with the value of
xx– Alan Thompson
Mar 28 at 18:09
Please update your question with the value of
xx– Alan Thompson
Mar 28 at 18:09
add a comment
|
1 Answer
1
active
oldest
votes
This is due to the order of arguments being passed to contains? by condp — it's passing the keyword as the first argument. If you create an anonymous function that swaps the argument order, it'll do what you want:
user=> (def xx :symbols #:a :b)
user=> (condp #(contains? %2 %1) (:symbols xx) :a (prn "yes"))
"yes"
nil
This is the relevant line from the condp doc string explaining that argument-order behavior:
For each clause, (pred test-expr expr) is evaluated.
Thank you for answering @TaylorWood !!
– Snehaa Ganesan
Mar 28 at 18:30
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404108%2fwhy-does-condp-contains-symbols-xx-a-prn-yes-give-contains-not-suppo%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is due to the order of arguments being passed to contains? by condp — it's passing the keyword as the first argument. If you create an anonymous function that swaps the argument order, it'll do what you want:
user=> (def xx :symbols #:a :b)
user=> (condp #(contains? %2 %1) (:symbols xx) :a (prn "yes"))
"yes"
nil
This is the relevant line from the condp doc string explaining that argument-order behavior:
For each clause, (pred test-expr expr) is evaluated.
Thank you for answering @TaylorWood !!
– Snehaa Ganesan
Mar 28 at 18:30
add a comment
|
This is due to the order of arguments being passed to contains? by condp — it's passing the keyword as the first argument. If you create an anonymous function that swaps the argument order, it'll do what you want:
user=> (def xx :symbols #:a :b)
user=> (condp #(contains? %2 %1) (:symbols xx) :a (prn "yes"))
"yes"
nil
This is the relevant line from the condp doc string explaining that argument-order behavior:
For each clause, (pred test-expr expr) is evaluated.
Thank you for answering @TaylorWood !!
– Snehaa Ganesan
Mar 28 at 18:30
add a comment
|
This is due to the order of arguments being passed to contains? by condp — it's passing the keyword as the first argument. If you create an anonymous function that swaps the argument order, it'll do what you want:
user=> (def xx :symbols #:a :b)
user=> (condp #(contains? %2 %1) (:symbols xx) :a (prn "yes"))
"yes"
nil
This is the relevant line from the condp doc string explaining that argument-order behavior:
For each clause, (pred test-expr expr) is evaluated.
This is due to the order of arguments being passed to contains? by condp — it's passing the keyword as the first argument. If you create an anonymous function that swaps the argument order, it'll do what you want:
user=> (def xx :symbols #:a :b)
user=> (condp #(contains? %2 %1) (:symbols xx) :a (prn "yes"))
"yes"
nil
This is the relevant line from the condp doc string explaining that argument-order behavior:
For each clause, (pred test-expr expr) is evaluated.
answered Mar 28 at 18:16
Taylor WoodTaylor Wood
13.1k1 gold badge9 silver badges27 bronze badges
13.1k1 gold badge9 silver badges27 bronze badges
Thank you for answering @TaylorWood !!
– Snehaa Ganesan
Mar 28 at 18:30
add a comment
|
Thank you for answering @TaylorWood !!
– Snehaa Ganesan
Mar 28 at 18:30
Thank you for answering @TaylorWood !!
– Snehaa Ganesan
Mar 28 at 18:30
Thank you for answering @TaylorWood !!
– Snehaa Ganesan
Mar 28 at 18:30
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404108%2fwhy-does-condp-contains-symbols-xx-a-prn-yes-give-contains-not-suppo%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Please update your question with the value of
xx– Alan Thompson
Mar 28 at 18:09