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 (some logic
On Sat, Jul 30, 2011 at 7:29 AM, Sam Aaron samaa...@gmail.com 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
On Jul 29, 2:02 pm, Ken Wesson kwess...@gmail.com 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
On Sat, Jul 30, 2011 at 9:07 PM, Alan Malloy a...@malloys.org 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
On Fri, Jul 29, 2011 at 12:49 AM, Jeff Rose ros...@gmail.com 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
On 29 Jul 2011, at 07:22, Ken Wesson wrote:
On Fri, Jul 29, 2011 at 12:49 AM, Jeff Rose ros...@gmail.com 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,
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 Jul 29, 1:49 am, Sam Aaron samaa...@gmail.com wrote:
On 29 Jul 2011, at 07:22, Ken Wesson wrote:
On Fri, Jul 29, 2011 at 12:49 AM, Jeff Rose ros...@gmail.com 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
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 English -
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
Actually, sadly,
On Fri, Jul 29, 2011 at 6:57 AM, Sam Aaron samaa...@gmail.com 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
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 7:35 AM, Sam Aaron samaa...@gmail.com 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
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)
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)
...]
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
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
On Thu, Jul 28, 2011 at 6:48 PM, Sam Aaron samaa...@gmail.com 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
*
On Jul 28, 3:48 pm, Sam Aaron samaa...@gmail.com 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 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= (bar
20 matches
Mail list logo