diff --git a/core-scala/pom.xml b/core-scala/pom.xml
new file mode 100644
index 0000000000..a5d6ac6e07
--- /dev/null
+++ b/core-scala/pom.xml
@@ -0,0 +1,53 @@
+
+
+ 4.0.0
+ core-scala
+ 1.0-SNAPSHOT
+ jar
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ org.scala-lang
+ scala-library
+ ${scala.version}
+
+
+
+
+ src/main/scala
+ src/test/scala
+
+
+ net.alchim31.maven
+ scala-maven-plugin
+ 3.3.2
+
+
+
+ compile
+ testCompile
+
+
+
+ -dependencyfile
+ ${project.build.directory}/.scala_dependencies
+
+
+
+
+
+
+
+
+
+ 2.11.8
+
+
+
diff --git a/core-scala/src/main/scala/com/baeldung/scala/Employee.scala b/core-scala/src/main/scala/com/baeldung/scala/Employee.scala
new file mode 100644
index 0000000000..3266b9a557
--- /dev/null
+++ b/core-scala/src/main/scala/com/baeldung/scala/Employee.scala
@@ -0,0 +1,10 @@
+package com.baeldung.scala
+
+class Employee(val name: String, var salary: Int, annualIncrement: Int = 20) extends AnyRef {
+
+ def incrementSalary(): Unit = {
+ salary += annualIncrement
+ }
+
+ override def toString = s"Employee(name=$name, salary=$salary)"
+}
\ No newline at end of file
diff --git a/core-scala/src/main/scala/com/baeldung/scala/HelloWorld.scala b/core-scala/src/main/scala/com/baeldung/scala/HelloWorld.scala
new file mode 100644
index 0000000000..fde03f2cb4
--- /dev/null
+++ b/core-scala/src/main/scala/com/baeldung/scala/HelloWorld.scala
@@ -0,0 +1,6 @@
+package com.baeldung.scala
+
+object HelloWorld extends App {
+ println("Hello World!")
+ args foreach println
+}
diff --git a/core-scala/src/main/scala/com/baeldung/scala/HigherOrderFunctions.scala b/core-scala/src/main/scala/com/baeldung/scala/HigherOrderFunctions.scala
new file mode 100644
index 0000000000..bab28d4f86
--- /dev/null
+++ b/core-scala/src/main/scala/com/baeldung/scala/HigherOrderFunctions.scala
@@ -0,0 +1,14 @@
+
+
+package com.baeldung.scala
+
+object HigherOrderFunctions {
+
+ def mapReduce(r: (Int, Int) => Int, i: Int, m: Int => Int, a: Int, b: Int) = {
+ def iter(a: Int, result: Int): Int = {
+ if (a > b) result
+ else iter(a + 1, r(m(a), result))
+ }
+ iter(a, i)
+ }
+}
\ No newline at end of file
diff --git a/core-scala/src/main/scala/com/baeldung/scala/Utils.scala b/core-scala/src/main/scala/com/baeldung/scala/Utils.scala
new file mode 100644
index 0000000000..af41685be9
--- /dev/null
+++ b/core-scala/src/main/scala/com/baeldung/scala/Utils.scala
@@ -0,0 +1,66 @@
+package com.baeldung.scala
+
+object Utils {
+ def average(x: Double, y: Double) = (x + y) / 2
+
+ def gcd(x: Int, y: Int): Int = {
+ if (y == 0) x else gcd(y, x % y)
+ }
+
+ def gcdIter(x: Int, y: Int): Int = {
+ var a = x
+ var b = y
+ while (b > 0) {
+ a = a % b
+ val t = a
+ a = b
+ b = t
+ }
+ return a
+ }
+
+ def rangeSum(a: Int, b: Int) = {
+ var sum = 0;
+ for (i <- a to b) {
+ sum += i
+ }
+ sum
+ }
+
+ def factorial(a: Int): Int = {
+ var result = 1;
+ var i = a;
+ do {
+ result *= i
+ i = i - 1
+ } while (i > 0)
+ result
+ }
+
+ def randomLessThan(d: Double) = {
+ var random = 0d
+ do {
+ random = Math.random()
+ } while (random >= d)
+ random
+ }
+
+ def whileLoop(condition: => Boolean)(body: => Unit): Unit =
+ if (condition) {
+ body
+ whileLoop(condition)(body)
+ }
+
+ def power(x: Int, y: Int): Int = {
+ def powNested(i: Int, accumulator: Int): Int = {
+ if (i <= 0) accumulator
+ else powNested(i - 1, x * accumulator)
+ }
+ powNested(y, 1)
+ }
+
+ def fibonacci(n: Int): Int = n match {
+ case 0 | 1 => 1
+ case x if x > 1 => fibonacci(x - 1) + fibonacci(x - 2)
+ }
+}
\ No newline at end of file
diff --git a/core-scala/src/test/scala/com/baeldung/scala/EmployeeUnitTest.scala b/core-scala/src/test/scala/com/baeldung/scala/EmployeeUnitTest.scala
new file mode 100644
index 0000000000..997a11a518
--- /dev/null
+++ b/core-scala/src/test/scala/com/baeldung/scala/EmployeeUnitTest.scala
@@ -0,0 +1,22 @@
+package com.baeldung.scala
+
+import org.junit.Test
+import org.junit.Assert._
+
+class EmployeeUnitTest {
+
+ @Test
+ def whenEmployeeSalaryIncremented_thenCorrectSalary() = {
+ val employee = new Employee("John Doe", 1000);
+ employee.incrementSalary();
+ assertEquals(1020, employee.salary);
+ }
+
+ @Test
+ def givenEmployee_whenToStringCalled_thenCorrectStringReturned() = {
+ val employee = new Employee("John Doe", 1000);
+ assertEquals("Employee(name=John Doe, salary=1000)", employee.toString);
+ }
+}
+
+
diff --git a/core-scala/src/test/scala/com/baeldung/scala/HigherOrderFunctionsUnitTest.scala b/core-scala/src/test/scala/com/baeldung/scala/HigherOrderFunctionsUnitTest.scala
new file mode 100644
index 0000000000..a939e38c25
--- /dev/null
+++ b/core-scala/src/test/scala/com/baeldung/scala/HigherOrderFunctionsUnitTest.scala
@@ -0,0 +1,44 @@
+package com.baeldung.scala
+
+import org.junit.Test
+import org.junit.Assert._
+import HigherOrderFunctions._
+
+class HigherOrderFunctionsUnitTest {
+
+ @Test
+ def whenCalledWithSumAndSquareFunctions_thenCorrectValueReturned = {
+ def square(x: Int) = x * x
+
+ def sum(x: Int, y: Int) = x + y
+
+ def sumSquares(a: Int, b: Int) =
+ mapReduce(sum, 0, square, a, b)
+
+ val n = 10
+ val expected = n * (n + 1) * (2 * n + 1) / 6
+ assertEquals(expected, sumSquares(1, n));
+ }
+
+ @Test
+ def whenComputingSumOfSquaresWithAnonymousFunctions_thenCorrectValueReturned = {
+ def sumSquares(a: Int, b: Int) =
+ mapReduce((x, y) => x + y, 0, x => x * x, a, b)
+
+ val n = 10
+ val expected = n * (n + 1) * (2 * n + 1) / 6
+ assertEquals(expected, sumSquares(1, n));
+ }
+
+ @Test
+ def givenCurriedFunctions_whenInvoked_thenCorrectValueReturned = {
+ def sum(f: Int => Int)(a: Int, b: Int): Int =
+ if (a > b) 0 else f(a) + sum(f)(a + 1, b)
+
+ def mod(n: Int)(x: Int) = x % n
+
+ def sumMod5 = sum(mod(5)) _
+
+ assertEquals(10, sumMod5(6,10));
+ }
+}
\ No newline at end of file
diff --git a/core-scala/src/test/scala/com/baeldung/scala/UtilsUnitTest.scala b/core-scala/src/test/scala/com/baeldung/scala/UtilsUnitTest.scala
new file mode 100644
index 0000000000..f4799ed552
--- /dev/null
+++ b/core-scala/src/test/scala/com/baeldung/scala/UtilsUnitTest.scala
@@ -0,0 +1,50 @@
+package com.baeldung.scala
+
+import org.junit.Test
+import Utils._
+import org.junit.Assert._
+
+class UtilsUnitTest {
+
+ @Test
+ def whenAverageCalled_thenCorrectValueReturned() = {
+ val average = Utils.average(10, 20)
+ assertEquals(15.0, average, 1e-5)
+ }
+
+ @Test
+ def givenTwoIntegers_whenGcdCalled_thenCorrectValueReturned = {
+ assertEquals(3, Utils.gcd(15, 27))
+ }
+
+ @Test
+ def givenTwoIntegers_whenGcdIterCalled_thenCorrectValueReturned = {
+ assertEquals(3, Utils.gcdIter(15, 27))
+ }
+
+ @Test
+ def givenTwoIntegers_whenRangeSumcalled_thenCorrectValueReturned = {
+ assertEquals(55, Utils.rangeSum(1, 10))
+ }
+
+ @Test
+ def givenPositiveInteger_whenFactorialInvoked_thenCorrectValueReturned = {
+ assertEquals(720, Utils.factorial(6))
+ }
+
+ @Test
+ def whenRandomLessThanInvokedWithANumber_thenARandomLessThanItReturned = {
+ val d = 0.1
+ assertTrue(Utils.randomLessThan(d) < d)
+ }
+
+ @Test
+ def whenPowerInvokedWith2And3_then8Returned = {
+ assertEquals(8, power(2, 3))
+ }
+
+ @Test
+ def whenFibonacciCalled_thenCorrectValueReturned = {
+ assertEquals(34, fibonacci(8))
+ }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 008d0aeac3..b412f01fb7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -377,6 +377,7 @@
guava-modules/guava-21
guice
disruptor
+ core-scala
spring-static-resources
hazelcast
hbase