阅读背景:

Solution to S-99 ( P01 ~ P05 )

来源:互联网 
  def last(data: List[Any]): Any = {
    if(data.size < 1)
      throw new IllegalArgumentException("List is too short")
    else
      return data.last
  }
  
  def penultimate(data: List[Any]): Any = {
    if(data.size < 2)
      throw new IllegalArgumentException("List is too short")
    else
      return data(data.size-2);
  }
  
  def nth(index: Int, data: List[Any]): Any = {
    if(data.size < index - 1)
      throw new IllegalArgumentException("Index is out of Range")
    else
      return data(index)
  }
  
  def length(data: List[Any]): Int = {
      return data.size
  }
  
  def reverse(data: List[Any]): List[Any] = {
      return data.reverse
  }  def last(data: List[Any]): Any = {
    if(dat



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: