How to generate a list of random numbers?

Ads
 

How to generate a list of random numbers?

Hi,

How to generate a list of random numbers?

I want code in scala programming language.

Thanks

View Answers

November 12, 2017 at 7:13 PM

HI,

You can use the code:

Seq.fill(10)(Random.nextInt)

This is example of Scala programming and it generates random integer.

Following program generates 10 random Integers. Here is the sample output:

scala> import scala.util.Random import scala.util.Random

scala> val s = Seq.fill(10)(Random.nextInt)
s: Seq[Int] = List(-1181870644, 1222939170, 818784821, 
1861087374, 1611361203, 1994029117, -1137498348, 
1659383584, -399814242, -1785355400)

scala>

Thanks

Ads









Related Tutorials/Questions & Answers:
How to generate a list of random numbers?
How do I generate random number?
Advertisements
how to generate random questions - Java Beginners
How to generate random number in java
Generate Random Numbers
Generate shuffling in the specified list
Generate array of random numbers without repetition
Generate random numbers in Java
generate random numbers and display the largest
Generate Random Integer Between Two Values in Scala
generate random integer matrix in r
Generate random number between two numbers in Scala
Generate random numbers from 1 to 100
Default constructor generate two random equations
Populating a list is Scala with random double
Generating Random Number
how to generate auto code ?
how to generate bank account number?
Generate array of random numbers
how to show random image in ASP.net?
How to create a random matrix in r?
How to generate XML from XSD?
how to generate code - Java Beginners
how to generate pdf file in struts
how to generate pdf file in struts
how to generate timetable - JSP-Servlet
J2ME Random Number
How to generate build.xml file
How to Generate Reports in Java - Java Beginners
how to select random rows from database through servlet
Version of taglibs>random dependency

Ads