arK()

What does arK() do?

arK() creates an array based on the values inside of it, repeated K times. For example, ar1(1, 2, 3, 4) makes the array [1, 2, 3, 4].

from ArrayExpressions import arrex
lst = [1, 2, 3, 4, 5]
output = arrex.evaluate(lst, "x == arL(I + 1)")
print(output) # True

This code showcases a useful way to use arK(). By supplying arK() with I, a list will be created in the form of [0, 1, ... K - 1]. By putting L for K, a list of the same length as x is created. So arL(I + 1), in the above example, creates a list of length 5 with elements of 1, 2, 3, 4, and 5. For a simpler example, look below.

Other Important Information:

InputComma separated values (if 1 value, no comma needed)
Does it create a new scope?No
OutputAn array containing every element repeated K times
KAny number, optional
IThe index of each element in the new array
Examplear4(1, 2)
Example ExplanationThis creates an array [1, 2, 1, 2, 1, 2, 1, 2]

l()

cvK()