Created
January 27, 2012 12:56
-
-
Save ryoco/1688649 to your computer and use it in GitHub Desktop.
stack List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
よりいい方法があったら誰かエロイ人教えてください |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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