Loading...

Category: Scala

List Replication in Scala

I’m still going through Scala bit by bit via HackerRank code tests, it’s taking me a little while to get going but the second challenge was, as per the question: Given a list, repeat each element in the list amount of times. The input and output portions will be handled automatically by the grader. You […]

Read more

Hacker Rank – Functional Programming in Scala

Print “Hello World” on a new line ‘n’ times. Challenge 2: object Solution { def main(args: Array[String]) { val sc = new java.util.Scanner (System.in); var n = sc.nextInt(); // Print “Hello World” on a new line ‘n’ times. f(5); } } def f(n: Int) = (1 to n) foreach(x => println(“Hello World”))

Read more