You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{"name":"generate_hundred","description":"Scala program to print numbers from 1 to 100 using for loop with until to determine loop range.","language":"Scala","code":["object ExampleForLoop2 {"," def main(args: Array[String]) {"," var counter: Int=0;",""," for(counter <- 1 until 101)"," print(counter + \"\");",""," // to print new line"," println();"," }","}"],"id":13,"tags":["math"]}
1
+
{"name":"generate_hundred","description":"Scala program to print numbers from 1 to 100 using for loop with until to determine loop range.","language":"Scala","code":["object ExampleForLoop2 {"," def main(args: Array[String]) {"," var counter: Int=0;",""," for(counter <- 1 until 101)"," print(counter + \"\");",""," // to print new line"," println();"," }","}"],"id":12,"tags":["math"]}
{"name":"life_exp_eur_asia","description":"Find countries in North America or Europe and Central Asia with a life expectancy in 2016 of 75 to 80.","language":"R","code":["eur_na_75_80 <- longevity %>%"," filter(life_expect > 75 & life_expect < 80 & (region == \"Europe & Central Asia\" | region == \"North America\")) %>%"," arrange(desc(life_expect))"],"id":9,"tags":["Countries Project"]}
1
+
{"name":"life_exp_eur_asia","description":"Find countries in North America or Europe and Central Asia with a life expectancy in 2016 of 75 to 80.","language":"R","code":["eur_na_75_80 <- longevity %>%"," filter(life_expect > 75 & life_expect < 80 & (region == \"Europe & Central Asia\" | region == \"North America\")) %>%"," arrange(desc(life_expect))"],"id":8,"tags":["Countries Project"]}
{"name":"parallel_strings","description":"A simple queue function to generate four random strings in parallel.","language":"Python","code":["import multiprocessing as mp","import random","import string","","random.seed(123)","","# Define an output queue","output = mp.Queue()","","# define a example function","def rand_string(length, output):"," \"\"\" Generates a random string of numbers, lower- and uppercase chars. \"\"\""," rand_str = ''.join(random.choice("," string.ascii_lowercase "," + string.ascii_uppercase "," + string.digits)"," for i in range(length))"," output.put(rand_str)","","# Setup a list of processes that we want to run","processes = [mp.Process(target=rand_string, args=(5, output)) for x in range(4)]","","# Run processes","for p in processes:"," p.start()","","# Exit the completed processes","for p in processes:"," p.join()","","# Get process results from the output queue","results = [output.get() for p in processes]","","print(results)"],"id":8,"tags":["multiprocessing"]}
1
+
{"name":"parallel_strings","description":"A simple queue function to generate four random strings in parallel.","language":"Python","code":["import multiprocessing as mp","import random","import string","","random.seed(123)","","# Define an output queue","output = mp.Queue()","","# define a example function","def rand_string(length, output):"," \"\"\" Generates a random string of numbers, lower- and uppercase chars. \"\"\""," rand_str = ''.join(random.choice("," string.ascii_lowercase "," + string.ascii_uppercase "," + string.digits)"," for i in range(length))"," output.put(rand_str)","","# Setup a list of processes that we want to run","processes = [mp.Process(target=rand_string, args=(5, output)) for x in range(4)]","","# Run processes","for p in processes:"," p.start()","","# Exit the completed processes","for p in processes:"," p.join()","","# Get process results from the output queue","results = [output.get() for p in processes]","","print(results)"],"id":16,"tags":["multiprocessing"]}
{"name":"sum_array","description":"Scala program of array. Declare, print, and calculate sum of all elements.","language":"Scala","code":["object ExampleArray1 {",""," def main(args: Array[String]) {",""," var numbers = Array(10,20,30,40,50);"," var N:Int=0;",""," //print all array elements"," println(\"All array elements: \");"," for ( N <- numbers ) {"," println(N);"," }"," //calculating SUM of all elements"," var sum: Int=0;"," for ( N <- numbers ) {"," sum+=N;"," } "," println(\"Sum of all array elements: \"+sum);",""," }","}"],"id":12,"tags":["math"]}
1
+
{"name":"sum_array","description":"Scala program of array. Declare, print, and calculate sum of all elements.","language":"Scala","code":["object ExampleArray1 {",""," def main(args: Array[String]) {",""," var numbers = Array(10,20,30,40,50);"," var N:Int=0;",""," //print all array elements"," println(\"All array elements: \");"," for ( N <- numbers ) {"," println(N);"," }"," //calculating SUM of all elements"," var sum: Int=0;"," for ( N <- numbers ) {"," sum+=N;"," } "," println(\"Sum of all array elements: \"+sum);",""," }","}"],"id":11,"tags":["math"]}
0 commit comments