Compare commits
No commits in common. "5365eabadd29b13c937cdd15bf1a6bd9fda20b3b" and "bed771a04ec81fa7ddc57652eb66ac4b517d8530" have entirely different histories.
5365eabadd
...
bed771a04e
34
README.md
34
README.md
@ -17,20 +17,12 @@
|
|||||||
* [Lesson 5 - Advanced lists and High order functions](#lesson-5---advanced-lists-and-high-order-functions)
|
* [Lesson 5 - Advanced lists and High order functions](#lesson-5---advanced-lists-and-high-order-functions)
|
||||||
* [Midterm preparation](#midterm-preparation)
|
* [Midterm preparation](#midterm-preparation)
|
||||||
* [Midterm](#midterm)
|
* [Midterm](#midterm)
|
||||||
* [Lesson 6 - Tuples and comprehensions](#lesson-6---tuples-and-comprehensions)
|
|
||||||
* [Lesson 7 - Advanced typing and infinite lists](#lesson-7---advanced-typing-and-infinite-lists)
|
|
||||||
* [Lesson 8 - Futures and parallel collections](#lesson-8---futures-and-parallel-collections)
|
|
||||||
* [Lesson 9 - DSLs](#lesson-9---dsls)
|
|
||||||
* [Assignments](#assignments)
|
* [Assignments](#assignments)
|
||||||
* [Assignment 1 - Square root](#assignment-1---square-root)
|
* [Assignment 1 - Square root](#assignment-1---square-root)
|
||||||
* [Assignment 2 - Map-reduce](#assignment-2---map-reduce)
|
* [Assignment 2 - Map-reduce](#assignment-2---map-reduce)
|
||||||
* [Assignment 3 - Binary tree](#assignment-3---binary-tree)
|
* [Assignment 3 - Binary tree](#assignment-3---binary-tree)
|
||||||
* [Assignment 4 - Lists and pattern matching](#assignment-4---lists-and-pattern-matching)
|
* [Assignment 4 - Lists and pattern matching](#assignment-4---lists-and-pattern-matching)
|
||||||
* [Assignment 5 - High-order functions on lists](#assignment-5---high-order-functions-on-lists)
|
* [Assignment 5 - High-order functions on lists](#assignment-5---high-order-functions-on-lists)
|
||||||
* [Assignment 6 - Sequence comprehension and tuples](#assignment-6---sequence-comprehension-and-tuples)
|
|
||||||
* [Assignment 7 - Advanced typing and infinite lists](#assignment-7---advanced-typing-and-infinite-lists)
|
|
||||||
* [Assignment 8 - Advanced typing and infinite lists](#assignment-8---advanced-typing-and-infinite-lists)
|
|
||||||
* [Assignment 9 - DSLs](#assignment-9---dsls)
|
|
||||||
<!-- TOC -->
|
<!-- TOC -->
|
||||||
|
|
||||||
|
|
||||||
@ -87,16 +79,6 @@
|
|||||||
- Variance, covariance and contra-variance
|
- Variance, covariance and contra-variance
|
||||||
- Infinite sequences
|
- Infinite sequences
|
||||||
|
|
||||||
### Lesson 8 - Futures and parallel collections
|
|
||||||
[Files](src/Lesson8)
|
|
||||||
- Futures
|
|
||||||
- Actors
|
|
||||||
- Parallel collections
|
|
||||||
|
|
||||||
### Lesson 9 - DSLs
|
|
||||||
[Files](src/Lesson9)
|
|
||||||
- DSL
|
|
||||||
|
|
||||||
## Assignments
|
## Assignments
|
||||||
|
|
||||||
### Assignment 1 - Square root
|
### Assignment 1 - Square root
|
||||||
@ -135,18 +117,4 @@
|
|||||||
### Assignment 6 - Sequence comprehension and tuples
|
### Assignment 6 - Sequence comprehension and tuples
|
||||||
[Files](src/Assignment6)
|
[Files](src/Assignment6)
|
||||||
- Tuples
|
- Tuples
|
||||||
- `for` comprehension
|
- `for` comprehension
|
||||||
|
|
||||||
### Assignment 7 - Advanced typing and infinite lists
|
|
||||||
[Files](src/Assignment7)
|
|
||||||
- Genericity
|
|
||||||
- Infinite lazy lists
|
|
||||||
|
|
||||||
### Assignment 8 - Advanced typing and infinite lists
|
|
||||||
[Files](src/Assignment8)
|
|
||||||
- Parallel collections
|
|
||||||
- Futures
|
|
||||||
|
|
||||||
### Assignment 9 - DSLs
|
|
||||||
[Files](src/Assignment9)
|
|
||||||
- DSL
|
|
@ -1,29 +0,0 @@
|
|||||||
import Assignment9.Kelvin.kel2cel
|
|
||||||
|
|
||||||
import scala.language.implicitConversions
|
|
||||||
|
|
||||||
|
|
||||||
package object Assignment9 {
|
|
||||||
sealed trait Temperature {
|
|
||||||
}
|
|
||||||
|
|
||||||
object Temperature {
|
|
||||||
implicit def cel2kel(celsius: Celsius): Kelvin = new Kelvin(celsius.value + 273.15)
|
|
||||||
implicit def kel2cel(kelvin: Kelvin): Celsius = new Celsius(kelvin.value - 273.15)
|
|
||||||
}
|
|
||||||
|
|
||||||
case class Celsius(value: Double) extends Temperature {
|
|
||||||
override def toString: String = s"$value°C"
|
|
||||||
}
|
|
||||||
object Celsius {
|
|
||||||
implicit def val2cel(value: Double): Celsius = new Celsius(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
case class Kelvin(value: Double) extends Temperature {
|
|
||||||
override def toString: String = s"$value K"
|
|
||||||
}
|
|
||||||
object Kelvin {
|
|
||||||
implicit def kel2cel(value: Double): Kelvin = new Kelvin(value)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package Assignment9
|
|
||||||
|
|
||||||
import scala.language.implicitConversions
|
|
||||||
|
|
||||||
object Ex1 extends App {
|
|
||||||
val a: Celsius = 30
|
|
||||||
val b: Kelvin = 30
|
|
||||||
val c: Kelvin = Celsius(10)
|
|
||||||
val d: Celsius = c
|
|
||||||
val e: Temperature = d
|
|
||||||
|
|
||||||
println(a) // Should print "30°C"
|
|
||||||
println(b) // Should print "30 K"
|
|
||||||
|
|
||||||
println()
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package Lesson9
|
|
||||||
|
|
||||||
import scala.language.{implicitConversions, postfixOps}
|
|
||||||
|
|
||||||
object PimpMyLibrary extends App{
|
|
||||||
/*class PimpedString(s: String) {
|
|
||||||
def increment: String = new String(s.toCharArray.map(_ + 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
implicit def str2Pimped(s: String): PimpedString = new PimpedString(s)
|
|
||||||
|
|
||||||
println("Hal" increment)*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user