https://github.com/sarthakmakhija/fp-in-scala
Repository containing the solutions to the problems from Functional Programming in Scala
https://github.com/sarthakmakhija/fp-in-scala
functional-programming scala scalatest
Last synced: 4 months ago
JSON representation
Repository containing the solutions to the problems from Functional Programming in Scala
- Host: GitHub
- URL: https://github.com/sarthakmakhija/fp-in-scala
- Owner: SarthakMakhija
- Created: 2017-11-27T12:26:20.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-08T10:11:14.000Z (almost 8 years ago)
- Last Synced: 2025-03-13T20:21:23.084Z (8 months ago)
- Topics: functional-programming, scala, scalatest
- Language: Scala
- Size: 25.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Functional Programming in Scala
This repository contains the solutions to the problems mentioned in *Manning Functional Pogramming in Scala.*
The project includes -
1. Scala
2. Scala test
3. Maven
Every exercise has its own scala file. Exercise 3.9 is written in a scala file - Exercise3_9 and the unit test for the same is
written is Exercise3_9Test
Eg;
```
package org.fp.scala
object Exercise3_9 {
def length[A](as: List[A]): Int = as.foldRight(0)((element: A, acc: Int) => acc + 1)
}
```
and the test for same -
```
package org.fp.scala
import org.scalatest.FlatSpec
class Exercise3_9Test extends FlatSpec {
it should "return 0 as the length of an empty list" in {
val length = Exercise3_9.length(List())
assert(length == 0)
}
it should "return 5 as the length of the list with 5 elements" in {
val length = Exercise3_9.length(List(1,2,3,4,5))
assert(length == 5)
}
}
```