What is Streams in Scala?

0 votes
Can anyone explain what streams in Scala?
Jul 25 in Apache Spark by Jina
25 views

1 answer to this question.

0 votes

Hi,

A stream is a lazy list as it evaluates elements only when it needs to. This lazy computation enhances program performance.

scala> val stream=177#::199#::69#::Stream.empty

stream: scala.collection.immutable.Stream[Int] = Stream(177, ?)

Since we don’t need the second element yet, Scala doesn’t evaluate it.

scala> val stream1=(1 to 7).toStream

stream1: scala.collection.immutable.Stream[Int] = Stream(1, ?)

scala> stream.head

Result:

res22: Int = 177
answered Jul 25 by Gitika
• 25,300 points

Related Questions In Apache Spark

0 votes
1 answer

What is ofDim in Scala?

Hey, ofDim() is a method in Scala that ...READ MORE

answered Jul 24 in Apache Spark by Gitika
• 25,300 points
31 views
0 votes
1 answer

What is exception propagation in Scala?

Hi, When a function experiences an exception, it ...READ MORE

answered Jul 25 in Apache Spark by Gitika
• 25,300 points
20 views
0 votes
1 answer

What is BitSet in Scala?

Hey, A BitSet is a set of non-negative ...READ MORE

answered Jul 25 in Apache Spark by Gitika
• 25,300 points
23 views
0 votes
1 answer

What is recursion in Scala function? How does it works?

Hey, A Scala function involves recursion when it ...READ MORE

answered Jul 25 in Apache Spark by Gitika
• 25,300 points
17 views
0 votes
1 answer
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,510 points
2,404 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,510 points
245 views
0 votes
10 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
12,232 views
0 votes
1 answer

What is “Unit” and “()” in Scala?

Hey, Unit is a subtype of scala.anyval and ...READ MORE

answered Jul 24 in Apache Spark by Gitika
• 25,300 points
27 views
0 votes
1 answer

What is the advantage of having immutability in design for Scala programming language?

Hi, Scala uses immutability by default in most ...READ MORE

answered Jul 24 in Apache Spark by Gitika
• 25,300 points
30 views