Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. package com.learner.s99
  2.  
  3. object P03 {
  4. def nth(n: Int, l: List[Any]): Any = {
  5. require(n >= 0, "n must be greater than or equal to zero")
  6. l match {
  7. case List() => None
  8. case head :: tail if n == 0 => head
  9. case head :: tail if n > 0 => nth(n - 1, tail)
  10. }
  11. }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement