Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. def divideLists(xs:List[Int]) : (List[Int] , List[Int]) =
  2. {
  3. if(xs.isEmpty) (Nil,Nil)
  4. else if(xs.head < 0 ) (xs.head::divideLists(xs.tail)._1,
  5. if(xs.head % 2 == 0) divideLists(xs.tail)._2 else xs.head::divideLists(xs.tail)._2)
  6. else divideLists(xs.tail)
  7. }
  8.  
  9. divideLists(List(-3, -6, 8, -9, 13))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement