mÅaam*─
Try it online.
Or alternatively, with the input-lists swapped:
^mæ~Ä_;
Try it online.
Explanation:
m # Map over the first (implicit) input-list,
Å # using two characters as inner code-block:
a # Wrap it into a list
a # Wrap that into a list
# (e.g. [6,0,0,6] → [[[6]],[[0]],[[0]],[[6]]])
m* # Repeat each the second (implicit) input amount of times
# (e.g. [5,1,1,0] and [[[6]],[[0]],[[0]],[[6]]] →
# [[[6,6,6,6,6]],[[0]],[[0]],[[]]])
─ # Flatten it to a single list
# (e.g. [[[6,6,6,6,6]],[[0]],[[0]],[[]]] → [6,6,6,6,6,0,0])
# (after which the entire stack is output implicitly as result)
Unfortunately, using m*
on lists [6,0,0,6]
and [5,1,1,0]
results in [30,0,0,0]
and lists [[6],[0],[0],[6]]
and [5,1,1,0]
results in [[30],[0],[0],[0]]
(apparently..). Hence the need for two wraps before we can use m*
.
^ # Zip the two (implicit) input-lists together
# (e.g. [5,1,1,0] and [6,0,0,6] → [[6,5],[0,1],[0,1],[6,0]]
m # Map over each inner pair,
æ # using 4 characters as inner code-block:
~ # Pop and push the contents of the pair separately to the stack
Ä # Pop the top, and loop that many times:
_ # Duplicate
; # After the inner loop, discard the top item
# (after which the entire stack is output implicitly as result)