Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure - map values

Tags:

clojure

I'm trying get a clojure function to detect if the value passed is a map. For example,

user=> (if-map {:foo 1}) ;Should return true
true 
user=> (if-map "hello") ;Returns false
false

Is there a pre-built function serving this already?

like image 590
Coding active Avatar asked Sep 28 '26 17:09

Coding active


1 Answers

Yes, map? is the inbuilt function

(map? {:a 1})
=> true

(map? [1])
=> false
like image 184
Mark Fisher Avatar answered Sep 30 '26 12:09

Mark Fisher



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!