Hi,
depending on your application you might use defnk (http://
richhickey.github.com/clojure-contrib/def-api.html#clojure.contrib.def/
defnk) to build your struct with default values.
Benjamin
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post
Just linking this diskussion to an earlier one:
http://groups.google.com/group/clojure/browse_thread/thread/b38a2754fd5b8104/fcd7c578238622f5
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Hi,
On 4 Okt., 04:40, John Harrop wrote:
> If you need to be creating these things dynamically, with information only
> available at runtime, defstruct is probably the wrong tool for the job, or
> the only struct member should be :name, and the levels at least should just
> be ordinary map keys
Hi,
On 4 Okt., 08:31, Meikel Brandmeyer wrote:
> The functions themselves can be easily made independent from the
> number of keys. Just save the keys in a constant.
>
> (defn process-department
> [department-struct]
> (->> +payment-levels+
> (map #(* (fee %) (department-struct %)))
> What macros do y'all have that you want to "apply" things to?
I am using structs and functions for workings with these structs.
Just some very general example:
(defstruct department :name :head :members-l1 :members-l2 ...)
(defn process-department [department-struct]
(reduce + (list
Hi
> Yes. You build up the code/data structure and pass it to either
> `eval' or `macroexpand', depending on your exact goals...
thx
> user=> (def args '(true false true false))
> #'user/args
> user=> (def code `(and ~...@args))
> #'user/code
> user=> code
> (clojure.core/and true false true fa
Hi,
some piece of code that helps me in this special case.
Here the "translated" version:
(defmacro apply-macro
[m & args]
`(list* ~m ~...@args))
(def li '(true false false))
(eval (apply-macro 'and true false li)) ; observe of the quote before
the macro
Or instead of trying sth. like:
(de
Hi Stuart,
> Nope, no can do.
>
> For an example of why, check out clojure.contrib.apply-macro -- the
> warnings are there for a reason.
For some reason I missed this library. Looks the same like the code I
wrote and declared as "to evil to use".
> "apply" is a function, so it's evaluated at ru
Hi everbody,
I am having some problems using macros which I will explain by using
the core macro 'and'.
Imagine having a macro accepting multiple arguments: (and true false
true false)
But all the arguments are in a list e.g. (def arglist '(true false
true false))
Is there a simple way to 'app