That works perfectly. I forgot about macroexpand-1...but I also didn't
think that the (1 2 3) list would be evaluated using 1 as a function
too.
Thanks both of you for the great help.
On May 12, 8:33 am, "J. McConnell" wrote:
> On Tue, May 12, 2009 at 11:22 AM, samppi wrote:
>
> > Oh, no...I u
On Tue, May 12, 2009 at 11:22 AM, samppi wrote:
>
> Oh, no...I understand now—it looks like I've incorrectly explained my
> problem.
>
> I want to use the macro like this: (a 1 2 3) equivalent to (m-seq [1 2
> 3]).
>
> Clojure 1.0.0-
> user=> (use 'clojure.contrib.monads)
> nil
> user=> (defn a [
Oh, no...I understand now—it looks like I've incorrectly explained my
problem.
I want to use the macro like this: (a 1 2 3) equivalent to (m-seq [1 2
3]).
Clojure 1.0.0-
user=> (use 'clojure.contrib.monads)
nil
user=> (defn a [& xs]
(with-monad maybe-m (m-seq xs)))
#'user/a
user=> (a 1 2 3)
(1 2
On May 12, 2009, at 16:40, samppi wrote:
> I thought that:
> `(with-monad maybe-m (m-seq ~xs)))
>
> would insert [1 2 3] where ~xs would be, becoming the list:
> (with-monad maybe-m (m-seq [1 2 3]))
It does, if you define your macro as
(defmacro b [xs]
`(with-monad maybe-m (m-seq ~xs)))
Bu
I see—thank you very much. But I suppose I don't understand how vector
expressions work in macros. I thought that using ~@ would get me an
argument error.
I thought that:
`(with-monad maybe-m (m-seq ~xs)))
would insert [1 2 3] where ~xs would be, becoming the list:
(with-monad maybe-m (m-seq [1
On 11.05.2009, at 23:17, samppi wrote:
> user=> (defmacro b [& xs]
> `(with-monad maybe-m (m-seq ~xs)))
> #'user/b
> user=> (b [1 2 3])
> java.lang.IllegalArgumentException: Wrong number of args passed to:
> LazilyPersistentVector (NO_SOURCE_FILE:0)
>
> So there's something wrong with how I'm phr
I'm having trouble using clojure.contrib.monads/m-seq in a macro.
Let's say that I just want to create a macro version of m-seq.
Clojure 1.0.0-
user=> (use 'clojure.contrib.monads)
nil
user=> (with-monad maybe-m (m-seq [1 2 3]))
(1 2 3)
user=> (defn a [& xs]
(with-monad maybe-m (m-seq [1 2 3])))