• + 4 comments

    In Scala:

    def f(arr:List[Int]):List[Int] = arr.zipWithIndex.filter(_._2 %2 == 1).map(_._1)
    

    So, zipWithIndex produces pairs like (28,0) (32,1) (5,2) ...

    ,where the second element is the index and the first the value in the list. Hold only those pairs for which the index is odd(filter), and return the first element of the pair which is the value(map) by applying the function which just describes holding only the first element of the pair.