How to use uniform list in Scala?

0 votes
Can anyone help with how to create uniform list in Scala?
Jul 31 in Apache Spark by Reshma
34 views

1 answer to this question.

0 votes

Hey,

The method List.fill() creates a list and fills it with zero or more copies of an element. 

scala> val f=List.fill(7)(1)

f: List[Int] = List(1, 1, 1, 1, 1, 1, 1)

This fills the list with seven instances of the integer 1.

answered Jul 31 by Gitika
• 25,340 points

Related Questions In Apache Spark

0 votes
1 answer

How to use yield keyword in scala and why it is used instead of println?

Hi, The yield keyword is used because the ...READ MORE

answered Jul 5 in Apache Spark by Gitika
• 25,340 points
58 views
0 votes
1 answer

How to use nested function in Scala?

Hey, With Scala, we can define a Scala ...READ MORE

answered Jul 26 in Apache Spark by Gitika
• 25,340 points
61 views
0 votes
1 answer

How to append a list in Scala?

Hey, For this purpose, we use the single ...READ MORE

answered Jul 26 in Apache Spark by Gitika
• 25,340 points
32 views
0 votes
1 answer

How to add third party java jars for use in PySpark?

You can add external jars as arguments ...READ MORE

answered Jul 4, 2018 in Apache Spark by nitinrawat895
• 10,670 points
1,222 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,670 points
2,687 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,670 points
282 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
13,375 views
0 votes
1 answer

How can you use "for" statement in scala to print list from collection?

Hi, You can use for loop in scala using ...READ MORE

answered Jul 5 in Apache Spark by Gitika
• 25,340 points
32 views
0 votes
1 answer

Which syntax to use to take the sum of list of collection in scala?

Hi, You can see this example to get ...READ MORE

answered Jul 5 in Apache Spark by Gitika
• 25,340 points
34 views