|
Scala example source code file (slices.scala)
The Scala slices.scala source codeobject Test extends App { // lists println(List(1, 2, 3, 4).slice(1, 2)) println(List(1, 2, 3, 4).slice(2, 1)) println(List(1, 2, 3, 4).slice(-1, 1)) println(List(1, 2, 3, 4).slice(1, -1)) println(List(1, 2, 3, 4).slice(-2, 2)) println println(List(1, 2, 3, 4) take 3) println(List(1, 2, 3) take 3) println(List(1, 2) take 3) println((List(): List[Int]) take 3) println(List[Nothing]() take 3) println println(List(1, 2, 3, 4) drop 3) println(List(1, 2, 3) drop 3) println(List(1, 2) drop 3) println((List(): List[Int]) drop 3) println(List[Nothing]() drop 3) println // arrays println(Array(1, 2, 3, 4).slice(1, 2).deep) println(Array(1, 2, 3, 4).slice(2, 1).deep) println(Array(1, 2, 3, 4).slice(-1, 1).deep) println(Array(1, 2, 3, 4).slice(1, -1).deep) println(Array(1, 2, 3, 4).slice(-2, 2).deep) println println(Array(1, 2, 3, 4) take 3 deep) println(Array(1, 2, 3) take 3 deep) println(Array(1, 2) take 3 deep) println((Array(): Array[Int]) take 3 deep) // println(Array[Nothing]() take 3) // contrib #757 println println(Array(1, 2, 3, 4) drop 3 deep) println(Array(1, 2, 3) drop 3 deep) println(Array(1, 2) drop 3 deep) println((Array(): Array[Int]) drop 3 deep) // println(Array[Nothing]() drop 3) println } Other Scala examples (source code examples)Here is a short list of links related to this Scala slices.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.