# Use a string with interpolations as function argument and interpolate later

**URL:** <https://discourse.julialang.org/t/use-a-string-with-interpolations-as-function-argument-and-interpolate-later/15505>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 26, 2018, 9:36am UTC](https://discourse.julialang.org/t/use-a-string-with-interpolations-as-function-argument-and-interpolate-later/15505 "2018-09-26T09:36:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stakaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stakaz/32/4740_2.png) [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Post date:** [September 26, 2018, 9:36am UTC](https://discourse.julialang.org/t/use-a-string-with-interpolations-as-function-argument-and-interpolate-later/15505/1 "2018-09-26T09:36:29Z")

</div>

Hello, I can use this code easily to produce a tuple (or array) of strings:

```julia
julia> Tuple("a$(a)_b$(b)" for (a,b) ∈ Iterators.product(1:2, 3:4))
("a1_b3", "a2_b3", "a1_b4", "a2_b4")

```

However I cannot make a function from this like:

```julia
julia> f(s) = Tuple(s for (a,b) ∈ Iterators.product(1:2, 3:4)); 
julia> f("a$(a)_b$(b)")
ERROR: LoadError: UndefVarError: a not defined

```

Is there a (complicated) way to define such a function via expressions and so on?

I really would love to have this but on my own I was not able to find a way of doing it…

Thanks.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [September 26, 2018, 9:41am UTC](https://discourse.julialang.org/t/use-a-string-with-interpolations-as-function-argument-and-interpolate-later/15505/2 "2018-09-26T09:41:03Z")

</div>

One way:

```julia
julia> f(s) = Tuple(s(a,b) for (a,b) ∈ Iterators.product(1:2, 3:4));

julia> f((a,b) -> "a$(a)_b$(b)")
("a1_b3", "a2_b3", "a1_b4", "a2_b4")

```

---

<div class="post-metadata">

**Author:** ![stakaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stakaz/32/4740_2.png) [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Post date:** [September 26, 2018, 9:41am UTC](https://discourse.julialang.org/t/use-a-string-with-interpolations-as-function-argument-and-interpolate-later/15505/3 "2018-09-26T09:41:51Z")

</div>

Yeah, that is great. Thanks…
