# Working around var-args with keywords

**URL:** https://clojureverse.org/t/working-around-var-args-with-keywords/2711
**Category:** How to?
**Tags:** clojure
**Created:** [August 23, 2018, 10:12pm UTC](https://clojureverse.org/t/working-around-var-args-with-keywords/2711 "2018-08-23T22:12:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Webdev\_Tory](https://clojureverse.org/user_avatar/clojureverse.org/webdev_tory/32/3781_2.png) [@Webdev\_Tory](https://clojureverse.org/u/Webdev_Tory)
#### Post date: [August 23, 2018, 10:12pm UTC](https://clojureverse.org/t/working-around-var-args-with-keywords/2711/1 "2018-08-23T22:12:34Z")

</div>

I’m working with incanter, but the pattern I’m concerned with is more general. Incanter has macros that takes args like this:

```
(charts/function-plot fn 0 num-points
                            :legend true
                            :series-label "Good conversations"
                            :x-label "Conversation Turn"
                            :y-label "Distance")

```

The problem is those keyword-value pairs, which are not encoded as a map. I can’t wrap this structure in a function that could optionally take a map of args like that (with ;`legend`, `:x-label`, etc). Is there some way I COULD transform a map into an unwrapped bunch of keyword/val like that? I’ve been hoping to get at it with combination of partial and eval, but that is further stopped by the fact that function-plot is a macro, not a function, so it can’t play with some higher-level functions.

---

<div class="post-metadata">

### Author: ![j-cr](https://clojureverse.org/letter_avatar_proxy/v4/letter/j/3bc359/32.png) [@j-cr](https://clojureverse.org/u/j-cr)
#### Post date: [August 23, 2018, 10:39pm UTC](https://clojureverse.org/t/working-around-var-args-with-keywords/2711/2 "2018-08-23T22:39:03Z")

</div>

For functions:

```auto
(apply f (apply concat {:a 1 :b 2}))
(apply f (into [] cat {:a 1 :b 2}))

```

For macros… without introducing another macro, you’re out of luck (though I guess I see no reason not to introduce one). You’ll have to write something like `:legend (:legend m)` for every kwarg. Are you sure the same interface isn’t exposed as functions somewhere? Incanter does provide the corresponding function-plot\* fn (to which the macro expands to), though I don’t know the details of exactly how you have to invoke it

---

<div class="post-metadata">

### Author: ![aisamu](https://clojureverse.org/user_avatar/clojureverse.org/aisamu/32/2397_2.png) [@aisamu](https://clojureverse.org/u/aisamu)
#### Post date: [August 24, 2018, 11:59am UTC](https://clojureverse.org/t/working-around-var-args-with-keywords/2711/3 "2018-08-24T11:59:44Z")

</div>

Would `medley`'s `mapply` work for you?

> <https://github.com/weavejester/medley/blob/aa64e3815e0b8280e0085bbcb1c9cd709bec63c3/src/medley/core.cljc#L145>

---

<div class="post-metadata">

### Author: ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)
#### Post date: [February 22, 2019, 11:59pm UTC](https://clojureverse.org/t/working-around-var-args-with-keywords/2711/4 "2019-02-22T23:59:45Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
