I was manipulation some data and used interpose at the end. But it acted differently when it comes to some letters like , ` ~
Expected behavior
(interpose '! ["a" "b" "c"])
=> ("a" ! "b" ! "c")
(interpose 'k ["a" "b" "c"])
=> ("a" k "b" k "c")
(interpose '- ["a" "b" "c"])
=> ("a" - "b" - "c")
Not Expected behavior (They return function instead of data result)
(interpose ', ["a" "b" "c"])
=> #object[clojure.core$interpose$fn__6471 0x6f0c27f3 "clojure.core$interpose$fn__6471@6f0c27f3"]
(interpose '` ["a" "b" "c"])
=> #object[clojure.core$interpose$fn__6471 0x7b94fbcb "clojure.core$interpose$fn__6471@7b94fbcb"]
(interpose '~ ["a" "b" "c"])
=> #object[clojure.core$interpose$fn__6471 0x36966945 "clojure.core$interpose$fn__6471@36966945"]
Those characters all have special meaning in Clojure and you simply can not enter them just with the quote. So they are handled with their meaning by the reader and then your '
quote is used for the next form. This all will lead to code that calls the one-arity version of interpose
, which then will give you a transducer, thus resulting in the functions you see as results.
If you want to have those characters as symbols, you can use symbol
. E.g.
user=> (interpose (symbol ",") ["a" "b" "c"])
("a" , "b" , "c")
The meanings of those characters are:
,
is a whitespace character`
and~
are syntax quote and unquote (mainly used in macros)
The resulting code with the unexpected behaviour looks basically like this then:
user=> `(interpose ', ["a" "b" "c"])
(clojure.core/interpose (quote ["a" "b" "c"]))
user=> `(interpose '` ["a" "b" "c"])
(clojure.core/interpose (quote (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list "a") (clojure.core/list "b") (clojure.core/list "c"))))))
user=> `(interpose '~ ["a" "b" "c"])
(clojure.core/interpose (quote ["a" "b" "c"]))