I'd like to generate the following number sequence in one go using a functional initialization construct:
Array(0, 0, 0, 0, 3, 3, 6, 6, 9, 9, ..., n*3, n*3)
One way is to do:
Array.fill[Int](2)(0) ++ Array.tabulate(4)(_*3)
but I'd need to double each value of the second part of the construct i.e. to get 0, 0
then 3, 3
etc. How can I duplicate the values of the second construct?
I also couldn't figure out a mathematical function that would generate such sequence.