[Question]
  [
Let us say that we have a particular set of functions on strings. These functions are kind of like fill in the blanks or madlibs, except that they only take one input and use that to fill in all of their blanks. For example we might have a function that looks like
```
I went to the ____ store and bought ____ today.
```
If we applied this function to the string `cheese` the result would be:
```
I went to the cheese store and bought cheese today.
```
We can represent these functions as a non-empty list of strings, where the blanks are simply the gaps in between strings. For example our function above would be:
```
["I went to the ", " store and bought ", " today."]
```
With this representation there is only one representation for every function of this sort and only one function for each representation.
A really neat thing is that the set of such functions is closed under composition. That is to say composition of two of our functions is always another one of these functions. For example if I compose our function above with
```
["blue ", ""]
```
(the function that prepends `blue` to the input)
We get the function:
```
["I went to the blue ", " store and bought blue ", " today."]
```
These can get a little more complex though. For example if we compose the first function with
```
["big ", " and ", ""]
```
The result is 
```
["I went to the big ", " and ", " store and bought big ", "and", " today."]
```
## Task
Your task is to take two functions as described as non-empty lists of strings and output their composition as a non-empty list of strings.
For the purpose of this challenge a list can be any ordered container that permits
duplicates and a string may be a native string type, a list of characters or a list of integers.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") answers will be scored in bytes with fewer bytes being better.
## Test cases
```
["","xy"] ["ab",""] -> ["ab","xy"]
["x","y","z"] ["a","b"] -> ["xa","bya","bz"]
["xy"] ["ab"] -> ["xy"]
["","",""] ["a",""] -> ["a","a",""]
["x",""] ["","",""] -> ["x","",""]
["x","y","z"] ["a","b","c"] -> ["xa","b","cya","b","cz"]
["x","x","x"] ["a"] -> ["xaxax"]
["w","x","y","z"] ["ab","cd","e"] -> ["wab","cd","exab","cd","eyab","cd","ez"]
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 6 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
j0j@ṣ0
```
A dyadic Link accepting the *first* function representation on the *right* and the *second* function representation on the *left* which yields the resulting function representation. Each function representation is a list of lists of characters (Jelly has no other strings).
**[Try it online!](https://tio.run/##y0rNyan8/z/LIMvh4c7FBv8PLz866eHOGf//RyslJinpKCnFAllAuqJSKRYA "Jelly – Try It Online")** (the full-program arguments are given in Python notation; strings become lists. The footer shows a Python representation of the Link's output.)
Here is a [test-suite](https://tio.run/##y0rNyan8/z/LIMvh4c7FBv8PL3fQz3J41LTmUeM@JaWsRw1zdYDcxn3RsZqR//9HR0crKekoVVQqxepEKyUmAdlKsbFcOkDhCiC7EoirIFJAVhJcCq4cKgDSBtIJVYhsBFgQJo/bZB2lZGRpCIZIQ4XLocJIOsHaUoBEKkhRLAA "Jelly – Try It Online") which reformats the Link's output like the inputs.
### How?
Takes advantage of Jelly's mixed type lists to allow the entire domain of representations (any list of lists of characters) by using the integer zero as a place-holder:
```
j0j@ṣ0 - Link: b, a        e.g.    b = [['a','b'],['c','d'],['e']]
       -                   ...and  a = [['w'],['x'],['y'],['z']]
                             (i.e. test-case ["w","x","y","z"] ["ab","cd","e"])
j0     - join b with zeros         ['a','b',0,'c','d',0,'e']    
  j@   - join a with that          ['w','a','b',0,'c','d',0,'e','x','a','b',0,'c','d',0,'e','y','a','b',0,'c','d',0,'e','z']
    ṣ0 - split at zeros            [['w','a','b'],['c','d'],['e','x','a','b'],['c','d'],['e','y','a','b'],['c','d'],['e','z']
                             (i.e.: ["wab","cd","exab","cd","eyab","cd","ez"])
```
---
If we needed to deal with any of Jelly's mixed lists (including those of any depth or shape) we could use this eight byter: `j,©⁹jœṣ®` which uses the paired arguments as the place-holder.
[Answer]
# [Haskell](https://www.haskell.org/), 78 bytes
```
(a:b:r)#t@(x:s)|s>[]=(a++x):init s++((last s++b):r)#t|z<-a++x++b=(z:r)#t
x#_=x
```
[Try it online!](https://tio.run/##hU/tCoMgFP2/pxDbD6N6gVhj7xExbAWLtTYySKV3b9dbhrXGEuV0rufDOxePsq7HkfE4j1vf6y5MxsIfxDnNEsaDQPpx1VQdEUHAWM0FotzHu4M@ReYKEAnTSB2kd03k@ORVQxJSvA7k3VZNR44kpTSkUtGMeIB5Dn@A118U2ZG56GolcAq2tnrA@UqPWom8wlNvHJzoba7rsAk2NbGpTf1RGibTdNt6li4@e5l2@P/FIb0tHs6LDa8WpL@dpm2d9ltwWGtlPytXPTCigKMEBpW9w0kHKwebTuMH "Haskell – Try It Online")
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), ~~60~~ 58 bytes
```
lambda a,b:(v:='&'.join(a+b)+'$').join(b).join(a).split(v)
```
An unnamed function accepting two lists of strings, `a` and `b`, which returns a list of strings.
**[Try it online!](https://tio.run/##LcdBDoIwEADAr/Rg3N3QcPFiSHgJctiF1tZg29SK8fUloKfJpG9xMVyuKVfb3@rCT5lZsZYO166HM7SP6ANyI9TACehX@cvUvtLiC65UU/ahoMUBWCbQCmZjd@7Ow6jVADGY/eUTD1w2x218ZxiJ6gY "Python 3.8 (pre-release) – Try It Online")** Or see the [test-suite](https://tio.run/##fY9ND4IgGMfP@ikYa8EzyUuX5mZfRD1A5qIVMnOmfXlChJmXDg/wf/nB0FN/a9XxpDvT5KV58KeoOeJMZHTIcrIn6b2VivJEQEJ2BBYp/M4hfemH7OkApmk7yyGBpEI0jmiBMcPjhCuGCsyFFbgC5oLRisnOx4f2KNZwRYI1szMeypuLFjtU/r3A8GVTWMYXQvD2wS/t0NouV1eDLI50J1VP5/8yREp1OBOGGqfBGQTMFw "Python 3.8 (pre-release) – Try It Online").
### How?
First forms a separator string, `v`, which cannot be found inside `a` or `b`. Then forms a string by joining up the strings in `b` with copies of `v`. Then forms a string by joining up the strings in `a` with copies of that. Finally splits that string at instances of `v` to give a list of strings.
While ensuring `v` is not in `a` or `b` we must also ensure that `v` wont make us split early in the case where all the strings in `a` and `b` are equal. To do so we form `v` by joining all the strings in both lists with instances of a string (here `'&'`) and add an extra, different character (here `'$'`). Note that doing either in isolation is not enough as all strings in the inputs could equal the chosen character.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), [~~4~~ ~~15~~ ~~19~~ ~~9~~ 11](https://www.youtube.com/watch?v=hlv672jqbtE) [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
«TýR©ý¹sý®¡
```
Unlike the Jelly answer, 05AB1E's string `"0"`, integer `0`, and float `0.0` are all (somewhat) equal, so I can't split/join by an integer. This is why we had the +15 bytes as workarounds, although I've golfed it back to 9 bytes now. Thanks to *@JonathanAllan* for finding 2 bugs.
[Try it online](https://tio.run/##yy9OTMpM/f//0OqQw3uDDq08vPfQzmIgse7Qwv//o5XKlXSUKoC4EoirlGK5opUSk4DM5BQgkaoUCwA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWVCsUtoscvRBf8PrbY8vPfQysN7I4qB9LpDC//r/I@OjlZS0lGqqFSK1YlWSkwCspViY3UUgMIVQHYlEFdBpICsJLgUXDlUAKQNpBOqENkIsCBMHrfJOkrJyNIQDJGGCpdDhZF0grWlAIlUmKKSjMxiIB9MgAwuSS0uAat1BHKcgNgZiF2A2BWI3bA4H9WlMXlADowASaMKQBQZGgC5MAKkyMAQyIYRsbGxAA).
**Explanation:**
```
«            # Merge the two (implicit) input-lists together
 Tý          # Then using a "10" delimiter join all strings together
   R         # Reverse this string
    ©        # Store this string in variable `®` (without popping)
     ý       # Use this string as delimiter to join the second (implicit) input-list
      ¹sý    # Then join the first input-list by this entire string
         ®¡  # And split it back on variable `®` so it's the expected list of strings
             # (after which this result is output implicitly)
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~62~~ 61 bytes
```
""<>#&/@Flatten[#~(R=Riffle)~I/.I->#2~R~I]~SequenceSplit~{I}&
```
[Try it online!](https://tio.run/##dYxPC4IwGMbvfox3IAUzoXOKp2C30KN4mLbRQKVikTa2r76mLvHS4X15@D1/OipvrKNSNNTyxAKcUhTG2bmlUrK@RGaXJ7ngvGV7Q@IDiVJ0NLkhlSnY48X6hhX3VkijiA7t5Sl6WaIo5VmGKjejAqUAMAwjaKyA1k6D1njCg9Oju89iOVWv1hr3YKpNTR/cTszw5/9fxtBs7eUW2@O3x5vmXLu6x1wo0PYL "Wolfram Language (Mathematica) – Try It Online")
-1 thanks to [Roman](https://codegolf.stackexchange.com/questions/188904/composing-fill-in-the-blanks/188941#comment452512_188941)
---
Though it's not a valid output, this returns a function that actually does the job.. (34 bytes)
```
(g=a""<>a~Riffle~#&)[#]@*g[#2]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7XyPdNvH9pIVKSjZ2iXVBmWlpOal1ymqa0cqxDlrp0cpGsWr/A0szU0scAooy80qilXXtNNIcHJQ1HZTi45Vi1fQdqrmqq5WUdJQqKpVqdaqVEpOAbKXaWh2QcAWQXQnEVRApICsJLgVXDhUAaQPphCpENgIsCJPHbbKOUjKyNARDpKHC5VBhJJ1gbSlAIhWoiKv2PwA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 8 bytes
Adapts [Jonathan's approach](https://codegolf.stackexchange.com/a/188923/58974).
```
qVqN²)qN
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=cVZxTrIpcU4&input=WyJ3IiwieCIsInkiLCJ6Il0gWyJhYiIsImNkIiwiZSJdCi1R)
```
qVqN²)qN     :Implicit input of arrays U & V (N=[U,V])
q            :Join U with
 Vq          :  V joined with
   N²        :    Push 2 to N (modifying the original), which gets coerced to a string
             >     e.g., N=[["a","b"],["c","d"]] -> N=[["a","b"],["c","d"],2] -> "a,b,c,d,2"
     )       :End join
      qN     :Split on the modified N, which, again, gets coerced to a string
             > e.g., N=[["a","b"],["c","d"],2] -> "a,b,c,d,2"
```
[Answer]
# [Haskell](https://www.haskell.org/), 62 bytes
```
[a]#(c:d)=(a++c):d
(a:b)#c=a:b#c
[a]%b=[a]
(a:b)%c=[a]#c#(b%c)
```
[Try it online!](https://tio.run/##JYpdCoAgEITfPcZugmInEDyJ@LBuQVFJVNDP5W0jGL75GGagfernudZICQ37zgZDzrH1nTLks0UOUshKDjoH4b9r/hwZTdZs60JjCes2lqOJcN3QguR8IOn4GWUBQ6ov "Haskell – Try It Online")
Here is my Haskell answer. It works on any type of list.
[Answer]
# [J](http://jsoftware.com/), ~~44~~ ~~43~~ ~~42~~ 29 bytes
```
_<;._1@,(;@}:@,@,.(,_&,)&.>/)
```
[Try it online!](https://tio.run/##fZDBDoIwDIbvPEXjgbJkTL2OaUhMPHnyBQggoF48spH47NjBBuNilo61fP/fde9xJxA6OElA4HAASZEKuNxv17FQmSiOOU@y/CtznnOR8CLmLBbnPRtZFLVW18VCJqWIX4LqVGzq5wcSLCvMUBtkkEpKfdLC/Ac9p0vKKkM7YDV4XFPRUAxOYhkv4VKtxsrbKuvrCEJIwjL/xeAWOGXOMxToCVxZvZBOFd7YCiorqM0m@z8AAZshSlqhYA43zdKvnx6sftDW6OBsgvPSt3c2Ye8Vw/EH "J – Try It Online")
*-13 bytes thanks to miles!*
This approach uses integers and is due to miles.
# original approach with strings
```
g=.[:}.@,,.
f=.(<@0<@;;._1@,];@g<"0@[)<@0<@g]
```
[Try it online!](https://tio.run/##fZBBDoMgEEX3noJ0M5pQYreCCfcwphGrNt10KZj07HRA0OmmISAf3//D8PJ@aUXXfITmXBRzK0qla6WlFPeb5r3Ui7rUuqvi6dL7opjG55uVMBiQYB1U7NqgzGJm@x/InB1QGYcrA7Nl3OKhw7klS2CyhTfqDFY5VoXcRCCClkrmL5BbQFQpkxpsBE/WHmRy0RsHgwmG0f2o/w0g8NPEgIMa9pm6Oeqt8cHGBy6TJXtH9kfdNcXQ2icG/gs "J – Try It Online")
*Note: I've adjusted -3 off the TIO to account for `f=.`*
Uses Jonathan Allen's method, adapted for J.
This was surprisingly difficult to golf, since J doesn't have a built in "join" method, and I'd be curious to see if it can be improved significantly.
`g` is helper verb that gives us "join"
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~85~~ 79 bytes
```
([a,...b],[c,...d])=>b.map(e=>r.push(r.pop(r.push(r.pop()+c,...d))+e),r=[a])&&r
```
[Try it online!](https://tio.run/##fY1NDsIgEIX3nqKZRcOkyAUMvQhhAZT6k1oIVNN6eZTW2Bh/NjPv5X0z76SuKppw9MO2d41NLU9EKMoY05IKk0UjkdeanZUnlteB@Us8kMdynrwZrBYcsbJIAxdKYlmGtDOuj66zrHN70hIBQAsYJ5C0EKB0diARNx/cmKMpj9sTzlr/gNeHX/O5Zq56ffrTulDrDWK6Aw "JavaScript (Node.js) – Try It Online")
[Answer]
# JavaScript, 37 bytes
[Also](https://codegolf.stackexchange.com/a/188932/58974) adapts [Jonathan's approach](https://codegolf.stackexchange.com/a/188923/58974).
```
a=>b=>a.join(b.join(a+=b+0)).split(a)
```
[Try it online](https://tio.run/##fY9BDoMgEEX3nsKwgmhJL4C7noKwAMRWY8QIaaGXpwi2GhddDHzmvz8TBv7kRi79bC@TblXoSOCkEaTheND9BEW@eEVEdUUIm3nsLeQoWGWsIZQWZUkBqIHzgNUUcBE1YEXUyXHx6WO9sxuVOLq/0N5b8@uIDT/NSv0v8ndLDeSJyJWJ3XltziGfwm081MqxIv0Vd3q5cfmAkLraM0QaqSejR4VHfYcddAh6hFD4AA)
[Answer]
# Perl 5 (`-lp`), 20 bytes
As @JonathanAllan commented, this is a full-program using, for IO, a tab as a list separator and a newline to separate the two lists.
```
chop($n=<>);s/  /$n/g
```
[TIO](https://tio.run/##PYrLCoAgFAXX536Hi1qEq1Y9/kVNKhCVDLI@vptBxGyGOSfazbXMZgmxEn7ox7pLElJ4OTMraMo4cZHSIOSTAFIo7ZVvgYYpXiBFB/6/mWDpDnFfg0/cuPgA)
the tab and newline were chosen because more convenient to check test cases, otherwise could be changed to non-printable characters `\1` and `\2`.
(`-02l012p`)
```
chop($n=<>);s//$n/g
```
[TIO](https://tio.run/##PYpJCoAwEATpeYsHPUhU8OTylyQGFUISVHB5vGMEkboU1R3MYmtmPfmQJq5r@6xZBUTixMgsoejAiYukAuE4CSCJ2F75Fijo6BGStOP/6wGGbh@22buV86KyRVmFBw)
How it works,
* `-02` : to set input record separator to `\2`
* `-l` : to remove input separator from default argument `$_` and to add output record separator to default output
* `-012` : to set output record separator to `\012` (`\n`) so that output is easier to check
* `-p` : to print default argument
* `$n=<>;` : to read next record and to assign to `$n`
* `chop$n;` : to remove separator from `$n`
* `s/\x1/$n/g` : to replace all occurences of `\1` with `$n`
[Answer]
# JavaScript (ES6), ~~62~~ 59 bytes
*Saved 3 bytes thanks to @Shaggy*
This is a fixed version of [Luis' answer](https://codegolf.stackexchange.com/a/188905/58563) (now deleted) to support all characters.
```
a=>b=>a.map(e=escape).join(b.map(e)).split`,`.map(unescape)
```
[Try it online!](https://tio.run/##jZBBDoIwEEX3nsJ01SYVTwAXMSYUrAaClAhK20O4ducNPJs3wKGt2pBihLT5zJ8@fqdkF9bmp6LpVrXY8WEfDyxOsjhh0ZE1mMe8zVnDSVSKosaZLRIStU1VdClNTeFcu64hF3UrKh5V4oD3eIMQRVKhLQHJMvgASZaTZ71eOndsXUwREgwFSzsMyGyKMQhpLGV2HQJ9gwRS@KBQjDG8ye8yzN8ETNsQvIolfGhhhnz7/02DotxHedMYLfVRegZolwPOZmLwBgC9A/ipzN92sHGLM4DeK0tPK0/r8OTp8367WjaoB/01u3eDOzO8AA "JavaScript (Node.js) – Try It Online")
]