Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(arr:List[Int]) : List[Int] = {
- def odd_concat(list_odd:List[Int], arr_index:Int) : List[Int] = {
- if(arr_index == arr.size) {
- list_odd
- }
- else if(arr_index % 2 == 0) {
- odd_concat(list_odd, arr_index + 1)
- }
- else {
- //println(arr(arr_index))
- list_odd:+arr(arr_index)
- odd_concat(list_odd, arr_index + 1)
- }
- }
- odd_concat(List(), 0)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement