{"id":3120,"date":"2016-02-09T13:45:10","date_gmt":"2016-02-09T13:45:10","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3120"},"modified":"2016-02-09T13:45:10","modified_gmt":"2016-02-09T13:45:10","slug":"scala-generate-a-list-of-random-numbers","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/scala-generate-a-list-of-random-numbers\/","title":{"rendered":"Scala &#8211; generate a list of random numbers"},"content":{"rendered":"<p>Using the scala fill operator, you can easily create a large list, and then populate that list with random entries:<\/p>\n<pre lang=\"scala\">\nval z = List.fill(1000)(10000).map(scala.util.Random.nextInt)\n<\/pre>\n<p>This will generate a list of 1,000 entries, each containing the number 10,000, which is used to generate a random number for that list entry (i.e. 0 to 10,000):<\/p>\n<pre>\nz: List[Int] = List(19436, 73559, 96382, 22910, 47398, 83820, 1630, 95466, 44891, 40060, 52702, 89086, 52120, 55565, 44399, 39384, 72965, 26512, 23219, 63453, 990, 37886, 2994, 86494, 41212, 46286, 65486, 44614, 35539, 72433, 9710, 20899, 62996, 12970, 75063, 61006, 3763, 44941, 89145, 32184, 56227, 61843, 93381, 3603, 75101, 81463, 47837, 61211, 86623, 38833, 83587, 287, 29393, 58860, 24595, 50864, 59747, 95237, 95245, 67748, 72658, 51490, 72874, 2855, 49481, 25293, 55248, 25664, 92292, 34892, 16992, 71963, 46768, 91903, 81261, 58776, 26798, 9205, 47431, 18671, 53079, 17322, 55733, 1277, 44473, 21537, 22465, 14512, 42176, 94234, 2286, 39820, 94704, 98961, 46788, 61623, 40974, 21683, 71372, 41895, 76286, 23357, 52151, 40870, 68518, 23155, 37816, 93887, 16082, 38841, 45650, 73544, 2289, ...\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Using the scala fill operator, you can easily create a large list, and then populate that list with random entries: val z = List.fill(1000)(10000).map(scala.util.Random.nextInt) This will generate a list of 1,000 entries, each containing the number 10,000, which is used to generate a random number for that list entry (i.e. 0 to 10,000): z: List[Int] &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/scala-generate-a-list-of-random-numbers\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Scala &#8211; generate a list of random numbers&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[480,482,485],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3120"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3120"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3120\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}