Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. def f(arr:List[Int]) : List[Int] = {
  2. def odd_concat(list_odd:List[Int], arr_index:Int) : List[Int] = {
  3. if(arr_index == arr.size) {
  4. list_odd
  5. }
  6. else if(arr_index % 2 == 0) {
  7. odd_concat(list_odd, arr_index + 1)
  8. }
  9. else {
  10. //println(arr(arr_index))
  11. list_odd:+arr(arr_index)
  12. odd_concat(list_odd, arr_index + 1)
  13. }
  14. }
  15. odd_concat(List(), 0)
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement