On Sat, Jul 30, 2011 at 9:07 PM, Alan Malloy wrote:
> (get :foo argmap__5673__auto 42) is the right way to solve this
> problem.
Is another way to solve it, yes, and a good one.
> Or if, as in the current example, you want to destructure a map with
> lots of defaults, simply:
>
> (let [{:keys [f
On Jul 29, 2:02 pm, Ken Wesson wrote:
> (fn [& args]
> (let [argmap__5673__auto (#'some-ns/parse-args args)
> foo (or (:foo argmap__5673__auto) 42)
> bar (or (:bar argmap__5673__auto) nil)
> ...]
> (body goes here)))
> where you define a private parse-args function in
On Sat, Jul 30, 2011 at 7:29 AM, Sam Aaron wrote:
>> (fn [& args]
>> (let [foo (some logic goes here)
>> bar (some logic goes here)
>> ...]
>> (body goes here)))
>
> I just finished implementing a solution and it looks exactly like this.
> You're absolutely right - this is preci
Hi Ken,
On 29 Jul 2011, at 22:02, Ken Wesson wrote:
>> P.S. Thanks everyone for your help so far. My brain is overheating but I am
>> learning a lot.
>
> You're welcome.
>
> To do what you're proposing you will probably need the emitted
> function to look like:
>
> (fn [& args]
> (let [foo (s
> P.S. Thanks everyone for your help so far. My brain is overheating but I am
> learning a lot.
You're welcome.
To do what you're proposing you will probably need the emitted
function to look like:
(fn [& args]
(let [foo (some logic goes here)
bar (some logic goes here)
...]
On 29 Jul 2011, at 12:56, Ken Wesson wrote:
>>>
>>
>> That seems to blow up
>
> How so?
(defn binding-vec [foos]
(vec (interleave names (take (count names) (repeat `(count ~foos))
(defmacro magic-fn
[& forms]
(let [args (gensym 'args)]
`(fn [& ~args]
(let ~(binding-vec args)
On Fri, Jul 29, 2011 at 7:35 AM, Sam Aaron wrote:
>
> On 29 Jul 2011, at 12:11, Ken Wesson wrote:
>>
>> Why not just (vec (interleave names (take (count names) (repeat
>> `(count ~foos)?
>>
>
> That seems to blow up
How so?
> The actual end goal is to be able to define a macro (or whatever)
On 29 Jul 2011, at 12:11, Ken Wesson wrote:
>
> Why not just (vec (interleave names (take (count names) (repeat
> `(count ~foos)?
>
That seems to blow up:
(defn binding-vec [foos]
(vec (interleave names (take (count names) (repeat `(count ~foos))
(defmacro magic-fn
[& forms]
(let
On Fri, Jul 29, 2011 at 6:57 AM, Sam Aaron wrote:
> However, something like the following doesn't work:
>
> (defn binding-vec [foos]
> `(vec (interleave ~names ~(take (count names) (repeat '`(count ~foos))
>
> A, because the above code is probably incorrect (I just cobbled it together
> for
Hi there,
On 29 Jul 2011, at 10:05, Alan Malloy wrote:
>
> (defn binding-vec [foos]
> ['size `(count ~foos)])
>
> (defmacro magic-fn
> [& forms]
> (let [args (gensym 'args)]
>`(fn [& ~args]
> (let ~(binding-vec args)
> ~@forms
>
> ((magic-fn (+ size 10)) 1 2) ;=> 12
Ac
Hi Alan,
On 29 Jul 2011, at 10:05, Alan Malloy wrote:
>>
>> Sorry, I was just trying to simplify things to try and get directly to the
>> meat of the problem.
>
> No apologies needed - reducing to a simple case is great. But here,
> the simplification was probably too severe.
>
Sorry, I'm Eng
On Jul 29, 1:49 am, Sam Aaron wrote:
> On 29 Jul 2011, at 07:22, Ken Wesson wrote:
>
> > On Fri, Jul 29, 2011 at 12:49 AM, Jeff Rose wrote:
> >> I don't think it's very typical to pass a form to a function, unless
> >> you plan on using eval at runtime.
>
> > Or it's a function called by a macro
On 29 Jul 2011, at 00:46, Kent wrote:
> I'm not sure what you're trying to do with this and, based on that
> ignorance, I'm not sure I think it's a great idea. Maybe you are being
> a bit crazy, and maybe your a genius. Who am I to say?
>
> Here is a function that does what you want. The only
On 29 Jul 2011, at 07:22, Ken Wesson wrote:
> On Fri, Jul 29, 2011 at 12:49 AM, Jeff Rose wrote:
>> I don't think it's very typical to pass a form to a function, unless
>> you plan on using eval at runtime.
>
> Or it's a function called by a macro to do some processing of forms.
Yep, this is p
On Fri, Jul 29, 2011 at 12:49 AM, Jeff Rose wrote:
> I don't think it's very typical to pass a form to a function, unless
> you plan on using eval at runtime.
Or it's a function called by a macro to do some processing of forms.
--
Protege: What is this seething mass of parentheses?!
Master: You
I don't think it's very typical to pass a form to a function, unless
you plan on using eval at runtime. If it doesn't need to happen at
runtime, then you'd do this with a macro approximately like this:
user=> (defmacro bar [f] `(fn [& args#] (let [~'size (count args#)]
~f)))
#'user/bar
user=> (ba
On Jul 28, 3:48 pm, Sam Aaron wrote:
> Hi there,
>
> I'm trying to create a fn which does the following:
>
> * returns a fn which takes an arbitrary number of args
> * calls a helper fn, passing the incoming args returning a vector of
> alternating symbols and vals
> * creates a let form using th
On Thu, Jul 28, 2011 at 6:48 PM, Sam Aaron wrote:
> Hi there,
>
> I'm trying to create a fn which does the following:
>
> * returns a fn which takes an arbitrary number of args
> * calls a helper fn, passing the incoming args returning a vector of
> alternating symbols and vals
> * creates a let
I'm not sure what you're trying to do with this and, based on that
ignorance, I'm not sure I think it's a great idea. Maybe you are being
a bit crazy, and maybe your a genius. Who am I to say?
Here is a function that does what you want. The only difference is
that my function also takes the "bin
Hi there,
I'm trying to create a fn which does the following:
* returns a fn which takes an arbitrary number of args
* calls a helper fn, passing the incoming args returning a vector of
alternating symbols and vals
* creates a let form using the vector of alternating symbols and vals returned
b
20 matches
Mail list logo