On Thu, Apr 19, 2012 at 7:28 AM, Thomas wrote:
> Hi,
>
> I'd like to write a macro which transforms
>
> (my-macro SomeClass. a b [x y] c [e f])
>
> into
>
> (SomeClass. a b x y c e f)
>
> (the order of collections and single values in the arguments should be
> arbitrary)
>
> The closest I came was
On Fri, Apr 20, 2012 at 11:14 AM, Marc Limotte wrote:
> Thomas,
>
> Try this:
>
> (defmacro my-macro2 [func & args] `(~func ~@(flatten (eval (vec args)
>
>
This won't work for:
(let [a [2 3]] (my-macro2 SomeClass. a))
--
You received this message because you are subscribed to the Google
Gr
Part of the problem is that you confuse compile time and runtime.
Macro are evaluated at compile-time.
So when you write:
(my-macro SomeClass. a b) , my-macro can't access the runtime value of a and b.
So if you want your second example to work, you need flatten to be
called at runtime and not
Thomas,
Try this:
(defmacro my-macro2 [func & args] `(~func ~@(flatten (eval (vec args)
Marc
On Wed, Apr 18, 2012 at 4:57 PM, thomas kalbe
wrote:
> Hi,
>
> I'd like to write a macro which transforms
>
> (my-macro SomeClass. a b [x y] c [e f])
>
> into
>
> (SomeClass. a b x y c e f)
>
> (t
Flatten isn't the problem. You can't put together a special form with
apply. Try taking the class name as a symbol or string and use reflection.
On Wednesday, April 18, 2012 1:57:27 PM UTC-7, Thomas wrote:
>
> Hi,
>
> I'd like to write a macro which transforms
>
> (my-macro SomeClass. a b [x y] c
Hi,
I'd like to write a macro which transforms
(my-macro SomeClass. a b [x y] c [e f])
into
(SomeClass. a b x y c e f)
(the order of collections and single values in the arguments should be
arbitrary)
The closest I came was
(defmacro my-macro [func & args]
`(~func ~@(flatten args)))
This
Hi,
I'd like to write a macro which transforms
(my-macro SomeClass. a b [x y] c [e f])
into
(SomeClass. a b x y c e f)
(the order of collections and single values in the arguments should be
arbitrary)
The closest I came was
(defmacro my-macro [func & args]
`(~func ~@(flatten args)))
Th
On Mon, Jan 25, 2010 at 3:09 AM, ataggart wrote:
>
> (zipmap
> (map keyword (take-nth 2 ~params))
> (map (comp var-get resolve) (take-nth 2 (next ~params
>
Neat :-) Thanks!
- Joel Rosario.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To po
On Mon, Jan 25, 2010 at 3:42 AM, Richard Newman wrote:
>> The former is a lot clearer to read, as it uses standard Clojure
>> datastructures.
>
> ... which offers other advantages beyond the human, such as
>
> (def page-names keys)
>
> user=> (page-names foobar)
> (:page :posts :post)
>
> Power co
The former is a lot clearer to read, as it uses standard Clojure
datastructures.
... which offers other advantages beyond the human, such as
(def page-names keys)
user=> (page-names foobar)
(:page :posts :post)
Power comes from algorithms × data structures, and hiding the data
structures —
On Jan 24, 5:05 pm, joel r wrote:
> It's meant to be called like this:
> (define-template some-template-name
> page some-function-1
> posts some-function-2
> post some-function-3)
>
> It defs a var called some-template-name bound to a map that looks like this:
> {:page some-function-1
> :p
On Jan 24, 9:05 am, joel r wrote:
> Hi,
>
> I was wondering whether there was an elegant way to make this macro do
> more work:
>
> (defmacro define-template [template-name & template-params]
> `(def ~template-name (apply merge (map (fn [[k# v#]]
> {
Hi,
I was wondering whether there was an elegant way to make this macro do
more work:
(defmacro define-template [template-name & template-params]
`(def ~template-name (apply merge (map (fn [[k# v#]]
{(keyword k#) (var-get
(resolve v#))})
13 matches
Mail list logo