On Monday, 15 February 2016, Sonny To wrote:
> I am trying to write a macro to unwrap a list:
>
> here's my naive attempt
>
> (defmacro unwrap [s]
> (-> s pr-str (clojure.string/replace #"[\(\)]" "") read-string))
>
> (unwrap (1 2 3) )
write a macro to unwrap a list:
>
> here's my naive attempt
>
> (defmacro unwrap [s]
> (-> s pr-str (clojure.string/replace #"[\(\)]" "") read-string))
>
> (unwrap (1 2 3) ) should give 1 2 3
>
> any ideas how this can be done?
>
> thank
What do you mean by "unwrap a list"?
If you mean something where:
(foo (unwrap 1 2 3)) == (foo 1 2 3)
Then I'm afraid this can't be done. A macro returns a single data structure.
- James
On 15 February 2016 at 18:54, Sonny To wrote:
> I am trying to write a
I am trying to write a macro to unwrap a list:
here's my naive attempt
(defmacro unwrap [s]
(-> s pr-str (clojure.string/replace #"[\(\)]" "") read-string))
(unwrap (1 2 3) ) should give 1 2 3
any ideas how this can be done?
thanks,
Sonny
--
You received