How to find max and min elements in a iterator with Scala

1 Answer

0 votes
object MyClass {
    def main(args: Array[String]): Unit = {
        val it1 = Iterator(1, 4, 5, 1, 9, 2, 8, 0, 7, 6);
        val it2 = Iterator(1, 4, 5, 1, 9, 2, 8, 0, 7, 6);
      
        println(it1.min);
        println(it2.max);
    }
}
     
     
     
     
/*
run:
     
0
9
     
*/

 



answered Jun 3, 2021 by avibootz

Related questions

1 answer 137 views
3 answers 110 views
1 answer 54 views
1 answer 52 views
1 answer 83 views
...