On Mon, Oct 5, 2009 at 2:38 PM, Meikel Brandmeyer wrote:
> Hi,
>
> Am 05.10.2009 um 19:29 schrieb cody koeninger:
>
> Here we have the smell! You cannot define functions with a function.
>>> You have to use a macro!
>>>
>>
>> I am not clear on what you mean by this. From a user's point of view,
Hi,
Am 05.10.2009 um 19:29 schrieb cody koeninger:
Here we have the smell! You cannot define functions with a function.
You have to use a macro!
I am not clear on what you mean by this. From a user's point of view,
what is the difference between defining a function, and interning a
var with
On Oct 4, 1:31 am, Meikel Brandmeyer wrote:
> Here we have the smell! You cannot define functions with a function.
> You have to use a macro!
I am not clear on what you mean by this. From a user's point of view,
what is the difference between defining a function, and interning a
var with a fn
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
On Sat, Oct 3, 2009 at 6:50 PM, b2m wrote:
> > What macros do y'all have that you want to "apply" things to?
> (defn init-funs [name & levels]
> (do
>(apply-macro create-department-struct name levels)
>(apply-macro create-process-department name levels)
>nil))
>
> A call like
> (ini
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 %)))
Hi,
Am 04.10.2009 um 00:50 schrieb b2m:
What macros do y'all have that you want to "apply" things to?
A sure code smell, IMO. It most likely is based on a misunderstanding
what macros are capable to do.
I am using structs and functions for workings with these structs.
Just some very gen
> 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
In the specific cases of "and" and "or", I made utility functions that do
non-short-circuiting "and" and "or" for use with "apply" and a stream of
boolean data. (Not sure which implementation is more efficient though: a
version that returns its argument with one argument, punts to the
appropriate m
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
On Oct 2, 12:47 pm, b2m wrote:
>
> But all the arguments are in a list e.g. (def arglist '(true false
> true false))
>
> Is there a simple way to 'apply' the macro to a list of arguments like
> it works for functions: (apply + '(1 2 3)) ?
>
Yes. You build up the code/data structure and pass i
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
On Oct 2, 12:47 pm, b2m wrote:
> Is there a simple way to 'apply' the macro to a list of arguments like
> it works for functions: (apply + '(1 2 3)) ?
Nope, no can do.
For an example of why, check out clojure.contrib.apply-macro -- the
warnings are there for a reason.
"apply" is a function, so
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
15 matches
Mail list logo