Re: Best way to pass through named arguments (destructured map)?

2013-09-10 Thread Gunnar Völkel
You can also checkout whether my library [1] suits you. Passing option maps 
to other functions with options and managing doc strings for these options 
(transitively) are the features it was written for. It will simplify 
functions with options in your own code but the calls to functions of third 
party libraries will remain the same.

[1] https://github.com/guv/clojure.options/

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Mark Mandel
Hey all,

Relatively new to Clojure, and I'm wondering if there is a better/simpler 
way to handle what I'm doing.

I'm working with the Elastisch library for interacting with ElasticSearch, 
and it has the following function:
http://reference.clojureelasticsearch.info/clojurewerkz.elastisch.rest.document.html#var-search

(search index mapping-type  {:as options})

That's all fine, except I want to call it from another function, to provide 
my default values for `index`, but still allow for the passthrough the 
options map for the `search` function.

The solution I came up with was:

(defn search
Search the mapping-type, with the given properties
[mapping-type  {:as options}]
(apply esd/search (reduce (fn [coll [k, v]] (conj coll k v)) [es-index 
mapping-type] options)))

Where `es-index` is already defined as a global def.

So basically I break the options apart into a vector, and apply it over the 
top of the esd/search function (where esd is the elastisch function defined 
earlier).

Does this make sense? Is there a better way?

It works, but wondering if there is an improvement I could make, especially 
as I could see myself doing this quite often.

Thanks in advance,

Mark


-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Ulises
If you're not planning on changing the value of your defined index,
you can always use partial, e.g.:

(def search (partial es/search es-index))

On 9 September 2013 09:42, Mark Mandel mark.man...@gmail.com wrote:
 Hey all,

 Relatively new to Clojure, and I'm wondering if there is a better/simpler
 way to handle what I'm doing.

 I'm working with the Elastisch library for interacting with ElasticSearch,
 and it has the following function:
 http://reference.clojureelasticsearch.info/clojurewerkz.elastisch.rest.document.html#var-search

 (search index mapping-type  {:as options})

 That's all fine, except I want to call it from another function, to provide
 my default values for `index`, but still allow for the passthrough the
 options map for the `search` function.

 The solution I came up with was:

 (defn search
 Search the mapping-type, with the given properties
 [mapping-type  {:as options}]
 (apply esd/search (reduce (fn [coll [k, v]] (conj coll k v)) [es-index
 mapping-type] options)))

 Where `es-index` is already defined as a global def.

 So basically I break the options apart into a vector, and apply it over the
 top of the esd/search function (where esd is the elastisch function defined
 earlier).

 Does this make sense? Is there a better way?

 It works, but wondering if there is an improvement I could make, especially
 as I could see myself doing this quite often.

 Thanks in advance,

 Mark


 --
 --
 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
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Meikel Brandmeyer (kotarak)
Hi,

Am Montag, 9. September 2013 10:42:57 UTC+2 schrieb Mark Mandel:


 (search index mapping-type  {:as options})



You don't have to use a map in the destructuring.

(defn search
  Docstring
  [mapping-type  options]
  (apply esd/search es-index mapping-type options))

Kind regards
Meikel
 

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Alex Fowler
I would also add that in case, if you *need* to destructure the `options` 
map for some reason, like:

`(defn search
  Docstring
  [mapping-type  {:keys [option-1 option-2] :as options}]
  (do-smth-with-option-1 ...)
  (apply esd/search es-index mapping-type options))`

then you can use `mapply` to apply maps to functions that accept optional 
args maps. The code of mapply is the fllowing:

`(defn mapply [f  args] (apply f (apply concat (butlast args) (last 
args`

Combining it with partial, as adviced, could give you the functionality you 
may sometimes need:

`(mapply (partial es/search es-index) your-options-map)`



понедельник, 9 сентября 2013 г., 12:42:57 UTC+4 пользователь Mark Mandel 
написал:

 Hey all,

 Relatively new to Clojure, and I'm wondering if there is a better/simpler 
 way to handle what I'm doing.

 I'm working with the Elastisch library for interacting with ElasticSearch, 
 and it has the following function:

 http://reference.clojureelasticsearch.info/clojurewerkz.elastisch.rest.document.html#var-search

 (search index mapping-type  {:as options})

 That's all fine, except I want to call it from another function, to 
 provide my default values for `index`, but still allow for the passthrough 
 the options map for the `search` function.

 The solution I came up with was:

 (defn search
 Search the mapping-type, with the given properties
 [mapping-type  {:as options}]
 (apply esd/search (reduce (fn [coll [k, v]] (conj coll k v)) [es-index 
 mapping-type] options)))

 Where `es-index` is already defined as a global def.

 So basically I break the options apart into a vector, and apply it over 
 the top of the esd/search function (where esd is the elastisch function 
 defined earlier).

 Does this make sense? Is there a better way?

 It works, but wondering if there is an improvement I could make, 
 especially as I could see myself doing this quite often.

 Thanks in advance,

 Mark




-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Meikel Brandmeyer (kotarak)
Hi,

Am Montag, 9. September 2013 12:31:30 UTC+2 schrieb Alex Fowler:

 I would also add that in case, if you *need* to destructure the `options` 
 map for some reason, like:

 `(defn search
   Docstring
   [mapping-type  {:keys [option-1 option-2] :as options}]
   (do-smth-with-option-1 ...)
   (apply esd/search es-index mapping-type options))`

 then you can use `mapply` to apply maps to functions that accept optional 
 args maps. The code of mapply is the fllowing:

 `(defn mapply [f  args] (apply f (apply concat (butlast args) (last 
 args`

 Combining it with partial, as adviced, could give you the functionality 
 you may sometimes need:

 `(mapply (partial es/search es-index) your-options-map)`


You don't have to destructure in the argument list:

(defn search
  [mapping-type  options]
  (let [{:keys [option-1]} options
index (index-based-on option-1)]
(apply esd/search index mapping-type options)))

Kind regards
Meikel

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Mark Mandel
Thanks for the help all, that gave me some things to think about.

Cheers,

Mark


On Mon, Sep 9, 2013 at 9:22 PM, Meikel Brandmeyer (kotarak) 
m...@kotka.dewrote:

 Hi,

 Am Montag, 9. September 2013 12:31:30 UTC+2 schrieb Alex Fowler:

 I would also add that in case, if you *need* to destructure the `options`
 map for some reason, like:

 `(defn search
   Docstring
   [mapping-type  {:keys [option-1 option-2] :as options}]
   (do-smth-with-option-1 ...)
   (apply esd/search es-index mapping-type options))`

 then you can use `mapply` to apply maps to functions that accept optional
 args maps. The code of mapply is the fllowing:

 `(defn mapply [f  args] (apply f (apply concat (butlast args) (last
 args`

 Combining it with partial, as adviced, could give you the functionality
 you may sometimes need:

 `(mapply (partial es/search es-index) your-options-map)`


 You don't have to destructure in the argument list:

 (defn search
   [mapping-type  options]
   (let [{:keys [option-1]} options
 index (index-based-on option-1)]
 (apply esd/search index mapping-type options)))

 Kind regards
 Meikel

  --
 --
 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
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
E: mark.man...@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

2 Devs from Down Under Podcast
http://www.2ddu.com/

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Mark Mandel
The solution I've actually gone with is:

(apply esd/search es-index mapping-type (- options seq flatten))

Seems the most consise and shows the intent of what I'm trying to do quite
well - better than a (relatively) confusing `reduce` statement.

Again, the help is appreciated.

Mark


On Tue, Sep 10, 2013 at 8:57 AM, Mark Mandel mark.man...@gmail.com wrote:

 Thanks for the help all, that gave me some things to think about.

 Cheers,

 Mark


 On Mon, Sep 9, 2013 at 9:22 PM, Meikel Brandmeyer (kotarak) 
 m...@kotka.dewrote:

 Hi,

 Am Montag, 9. September 2013 12:31:30 UTC+2 schrieb Alex Fowler:

 I would also add that in case, if you *need* to destructure the
 `options` map for some reason, like:

 `(defn search
   Docstring
   [mapping-type  {:keys [option-1 option-2] :as options}]
   (do-smth-with-option-1 ...)
   (apply esd/search es-index mapping-type options))`

 then you can use `mapply` to apply maps to functions that accept
 optional args maps. The code of mapply is the fllowing:

 `(defn mapply [f  args] (apply f (apply concat (butlast args) (last
 args`

 Combining it with partial, as adviced, could give you the functionality
 you may sometimes need:

 `(mapply (partial es/search es-index) your-options-map)`


 You don't have to destructure in the argument list:

 (defn search
   [mapping-type  options]
   (let [{:keys [option-1]} options
 index (index-based-on option-1)]
 (apply esd/search index mapping-type options)))

 Kind regards
 Meikel

  --
 --
 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
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




 --
 E: mark.man...@gmail.com
 T: http://www.twitter.com/neurotic
 W: www.compoundtheory.com

 2 Devs from Down Under Podcast
 http://www.2ddu.com/




-- 
E: mark.man...@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

2 Devs from Down Under Podcast
http://www.2ddu.com/

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Leif
Careful - `flatten` recursively flattens sequential things.  E.g.
(flatten (seq {:in [1 2 3]})) = '(:in 1 2 3), which is probably not what 
you want.

You really want `flatten1`, which doesn't exist in core.  A version that 
works on maps is
(apply concat {:in [1 2 3]}) = '(:in [1 2 3]).  This appears within Alex's 
solution.

I would personally go with Meikel's solution, though.  It seems the nicest.

--Leif

On Monday, September 9, 2013 7:02:43 PM UTC-4, Mark Mandel wrote:

 The solution I've actually gone with is:

 (apply esd/search es-index mapping-type (- options seq flatten))

 Seems the most consise and shows the intent of what I'm trying to do quite 
 well - better than a (relatively) confusing `reduce` statement.

 Again, the help is appreciated.

 Mark


 On Tue, Sep 10, 2013 at 8:57 AM, Mark Mandel mark@gmail.comjavascript:
  wrote:

 Thanks for the help all, that gave me some things to think about.

 Cheers,

 Mark


 On Mon, Sep 9, 2013 at 9:22 PM, Meikel Brandmeyer (kotarak) 
 m...@kotka.de javascript: wrote:

 Hi,

 Am Montag, 9. September 2013 12:31:30 UTC+2 schrieb Alex Fowler:

 I would also add that in case, if you *need* to destructure the 
 `options` map for some reason, like:

 `(defn search
   Docstring
   [mapping-type  {:keys [option-1 option-2] :as options}]
   (do-smth-with-option-1 ...)
   (apply esd/search es-index mapping-type options))`

 then you can use `mapply` to apply maps to functions that accept 
 optional args maps. The code of mapply is the fllowing:

 `(defn mapply [f  args] (apply f (apply concat (butlast args) (last 
 args`

 Combining it with partial, as adviced, could give you the functionality 
 you may sometimes need:

 `(mapply (partial es/search es-index) your-options-map)`


 You don't have to destructure in the argument list:

 (defn search
   [mapping-type  options]
   (let [{:keys [option-1]} options
 index (index-based-on option-1)]
 (apply esd/search index mapping-type options)))

 Kind regards
 Meikel

  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




 -- 
 E: mark@gmail.com javascript:
 T: http://www.twitter.com/neurotic
 W: www.compoundtheory.com

 2 Devs from Down Under Podcast
 http://www.2ddu.com/
  



 -- 
 E: mark@gmail.com javascript:
 T: http://www.twitter.com/neurotic
 W: www.compoundtheory.com

 2 Devs from Down Under Podcast
 http://www.2ddu.com/
  

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Matt Mitchell
And also:

(mapcat identity {:in [1 2 3]}) = '(:in [1 2 3])

But yeah, destructuring with ** then using *apply* is pretty clear too.

- Matt

On Monday, September 9, 2013 10:41:12 PM UTC-4, Leif wrote:

 Careful - `flatten` recursively flattens sequential things.  E.g.
 (flatten (seq {:in [1 2 3]})) = '(:in 1 2 3), which is probably not what 
 you want.

 You really want `flatten1`, which doesn't exist in core.  A version that 
 works on maps is
 (apply concat {:in [1 2 3]}) = '(:in [1 2 3]).  This appears within 
 Alex's solution.

 I would personally go with Meikel's solution, though.  It seems the nicest.

 --Leif

 On Monday, September 9, 2013 7:02:43 PM UTC-4, Mark Mandel wrote:

 The solution I've actually gone with is:

 (apply esd/search es-index mapping-type (- options seq flatten))

 Seems the most consise and shows the intent of what I'm trying to do 
 quite well - better than a (relatively) confusing `reduce` statement.

 Again, the help is appreciated.

 Mark


 On Tue, Sep 10, 2013 at 8:57 AM, Mark Mandel mark@gmail.com wrote:

 Thanks for the help all, that gave me some things to think about.

 Cheers,

 Mark


 On Mon, Sep 9, 2013 at 9:22 PM, Meikel Brandmeyer (kotarak) 
 m...@kotka.de wrote:

 Hi,

 Am Montag, 9. September 2013 12:31:30 UTC+2 schrieb Alex Fowler:

 I would also add that in case, if you *need* to destructure the 
 `options` map for some reason, like:

 `(defn search
   Docstring
   [mapping-type  {:keys [option-1 option-2] :as options}]
   (do-smth-with-option-1 ...)
   (apply esd/search es-index mapping-type options))`

 then you can use `mapply` to apply maps to functions that accept 
 optional args maps. The code of mapply is the fllowing:

 `(defn mapply [f  args] (apply f (apply concat (butlast args) (last 
 args`

 Combining it with partial, as adviced, could give you the 
 functionality you may sometimes need:

 `(mapply (partial es/search es-index) your-options-map)`


 You don't have to destructure in the argument list:

 (defn search
   [mapping-type  options]
   (let [{:keys [option-1]} options
 index (index-based-on option-1)]
 (apply esd/search index mapping-type options)))

 Kind regards
 Meikel

  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to clojure+u...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




 -- 
 E: mark@gmail.com
 T: http://www.twitter.com/neurotic
 W: www.compoundtheory.com

 2 Devs from Down Under Podcast
 http://www.2ddu.com/
  



 -- 
 E: mark@gmail.com
 T: http://www.twitter.com/neurotic
 W: www.compoundtheory.com

 2 Devs from Down Under Podcast
 http://www.2ddu.com/
  


-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Mark Mandel
I like that mapcat solution a lot. Very nice.

For some reason I can't get the destructuring to work... clearly missing
something there.

But fair point on the flatten - I had a play with it, and I can clearly see
the issue.

Thanks for the extra help.

Mark


On Tue, Sep 10, 2013 at 2:17 PM, Matt Mitchell goodie...@gmail.com wrote:

 And also:

 (mapcat identity {:in [1 2 3]}) = '(:in [1 2 3])

 But yeah, destructuring with ** then using *apply* is pretty clear too.

 - Matt

 On Monday, September 9, 2013 10:41:12 PM UTC-4, Leif wrote:

 Careful - `flatten` recursively flattens sequential things.  E.g.
 (flatten (seq {:in [1 2 3]})) = '(:in 1 2 3), which is probably not what
 you want.

 You really want `flatten1`, which doesn't exist in core.  A version that
 works on maps is
 (apply concat {:in [1 2 3]}) = '(:in [1 2 3]).  This appears within
 Alex's solution.

 I would personally go with Meikel's solution, though.  It seems the
 nicest.

 --Leif

 On Monday, September 9, 2013 7:02:43 PM UTC-4, Mark Mandel wrote:

 The solution I've actually gone with is:

 (apply esd/search es-index mapping-type (- options seq flatten))

 Seems the most consise and shows the intent of what I'm trying to do
 quite well - better than a (relatively) confusing `reduce` statement.

 Again, the help is appreciated.

 Mark


 On Tue, Sep 10, 2013 at 8:57 AM, Mark Mandel mark@gmail.com wrote:

 Thanks for the help all, that gave me some things to think about.

 Cheers,

 Mark


 On Mon, Sep 9, 2013 at 9:22 PM, Meikel Brandmeyer (kotarak) 
 m...@kotka.de wrote:

 Hi,

 Am Montag, 9. September 2013 12:31:30 UTC+2 schrieb Alex Fowler:

 I would also add that in case, if you *need* to destructure the
 `options` map for some reason, like:

 `(defn search
   Docstring
   [mapping-type  {:keys [option-1 option-2] :as options}]
   (do-smth-with-option-1 ...)
   (apply esd/search es-index mapping-type options))`

 then you can use `mapply` to apply maps to functions that accept
 optional args maps. The code of mapply is the fllowing:

 `(defn mapply [f  args] (apply f (apply concat (butlast args) (last
 args`

 Combining it with partial, as adviced, could give you the
 functionality you may sometimes need:

 `(mapply (partial es/search es-index) your-options-map)`


 You don't have to destructure in the argument list:

 (defn search
   [mapping-type  options]
   (let [{:keys [option-1]} options
 index (index-based-on option-1)]
 (apply esd/search index mapping-type options)))

 Kind regards
 Meikel

  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com
 Note that posts from new members are moderated - please be patient
 with your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+u...@googlegroups.com.
 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .




 --
 E: mark@gmail.com
 T: http://www.twitter.com/**neurotic http://www.twitter.com/neurotic
 W: www.compoundtheory.com

 2 Devs from Down Under Podcast
 http://www.2ddu.com/




 --
 E: mark@gmail.com
 T: http://www.twitter.com/**neurotic http://www.twitter.com/neurotic
 W: www.compoundtheory.com

 2 Devs from Down Under Podcast
 http://www.2ddu.com/

  --
 --
 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
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
E: mark.man...@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

2 Devs from Down Under Podcast
http://www.2ddu.com/

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message