|
Scala example source code file (scan.scala)
The Scala scan.scala source codeobject Test { def main(args: Array[String]) { val lst = List(1, 2, 3, 4, 5) assert(lst.scanLeft(0)(_ + _) == List(0, 1, 3, 6, 10, 15)) assert(lst.scanRight(0)(_ + _) == List(15, 14, 12, 9, 5, 0)) val emp = List[Int]() assert(emp.scanLeft(0)(_ + _) == List(0)) assert(emp.scanRight(0)(_ + _) == List(0)) val stream = Stream(1, 2, 3, 4, 5) assert(stream.scanLeft(0)(_ + _) == Stream(0, 1, 3, 6, 10, 15)) assert(Stream.from(1).scanLeft(0)(_ + _).take(5) == Stream(0, 1, 3, 6, 10)) } } Other Scala examples (source code examples)Here is a short list of links related to this Scala scan.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.