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<javascript:> > > 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.com<javascript:> >>> 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.