Atom - x - Replicate

Characters: x

Tags: array , number , vectorize

Arity: dyadic

This atom is dyadic, which means it takes two arguments.

Functionality

Repeat each element of x y times. Vectorizes at depth 1 on the left and then vectorizes between the elements.

Details

y must be a list of only numbers or a number, otherwise an error will occur. This repeats each element of x in-place, so 1,2,3,4 x 2,1,3,2 returns [1, 1, 2, 3, 3, 3, 4, 4]. If the right argument consists of only 0 and 1, this works to apply a boolean mask to a list.