[Solved] Clojure macro not working?

Hi,

I used a basic macro here to switch the order of a list:

(defmacro prefix [exp] (list (second exp) (first exp) (last exp)))
(println (macroexpand '(prefix (5 * x))))

In IDE here:

Standard Output Stream:

(prefix (5 * x))
which didn’t work.

In my own PC:
(* 5 x)
which works well.

What could be the reason?
Thanks!

Your solution in the IDE is most likely in the Solution namespace, whereas your quote isn’t.

Try this:

(println (macroexpand '(Solution/prefix (5 * x))))

1 Like

Hi JBM,
It is working. Thanks a lot!

2 Likes