Skip to content

Instantly share code, notes, and snippets.

@ryoco
Created January 27, 2012 12:56
Show Gist options
  • Save ryoco/1688649 to your computer and use it in GitHub Desktop.
Save ryoco/1688649 to your computer and use it in GitHub Desktop.
stack List
よりいい方法があったら誰かエロイ人教えてください
stackList(List(1.0,2.0,3.0,4.0,5.0).reverse).reverse
res: List[Double] = List(1.0,3.0,6.0,10.0,15.0)
//stack List
def stackList(l:List[Double]):List[Double] =
l match {
case Nil => l
case x::xs => l.sum::stackList(xs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment